Skip to content

Commit

Permalink
refactor(url): not finding a short link for a user should be construe…
Browse files Browse the repository at this point in the history
…d as unauthorized update
  • Loading branch information
liangyuanruo committed Sep 28, 2020
1 parent 86a5de3 commit 2563b1f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class UserController implements UserControllerInterface {
return
} catch (error) {
if (error instanceof NotFoundError) {
res.notFound(jsonMessage(error.message))
res.forbidden(jsonMessage(error.message))
return
}
logger.error(`Error editing URL:\t${error}`)
Expand Down
3 changes: 3 additions & 0 deletions src/server/util/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ response.badRequest = function (content) {
response.unauthorized = function (content) {
this.status(401).send(content)
}
response.forbidden = function (content) {
this.status(403).send(content)
}
response.notFound = function (content) {
this.status(404).send(content)
}
Expand Down
1 change: 1 addition & 0 deletions src/types/server/api/express.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare global {
created(content?: Buffer | object | string): void
badRequest(content?: Buffer | object | string): void
unauthorized(content?: Buffer | object | string): void
forbidden(content?: Buffer | object | string): void
notFound(content?: Buffer | object | string): void
unsupportedMediaType(content?: Buffer | object | string): void
unprocessableEntity(content?: Buffer | object | string): void
Expand Down

0 comments on commit 2563b1f

Please sign in to comment.