summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2023-06-26 03:09:12 +0200
committerGitHub <noreply@github.com>2023-06-26 10:09:12 +0900
commitd23ad8b5117a46067464d1b693ae8898d127d5fc (patch)
tree412b9236b2265e4cb74dc0192d6e3882747c666a /packages/backend/src/server/api
parentrefactor(backend): use node16 for moduleResolution (#10938) (diff)
downloadsharkey-d23ad8b5117a46067464d1b693ae8898d127d5fc.tar.gz
sharkey-d23ad8b5117a46067464d1b693ae8898d127d5fc.tar.bz2
sharkey-d23ad8b5117a46067464d1b693ae8898d127d5fc.zip
fix(backend): APIエラーのHTTP status code変更 (#11047)
Diffstat (limited to 'packages/backend/src/server/api')
-rw-r--r--packages/backend/src/server/api/ApiCallService.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts
index dad1a4132a..45fb473763 100644
--- a/packages/backend/src/server/api/ApiCallService.ts
+++ b/packages/backend/src/server/api/ApiCallService.ts
@@ -83,7 +83,7 @@ export class ApiCallService implements OnApplicationShutdown {
}
}).catch(err => {
if (err instanceof AuthenticationError) {
- this.send(reply, 403, new ApiError({
+ this.send(reply, 401, new ApiError({
message: 'Authentication failed. Please ensure your token is correct.',
code: 'AUTHENTICATION_FAILED',
id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14',
@@ -137,7 +137,7 @@ export class ApiCallService implements OnApplicationShutdown {
}
}).catch(err => {
if (err instanceof AuthenticationError) {
- this.send(reply, 403, new ApiError({
+ this.send(reply, 401, new ApiError({
message: 'Authentication failed. Please ensure your token is correct.',
code: 'AUTHENTICATION_FAILED',
id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14',
@@ -278,6 +278,7 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError({
message: 'You are not assigned to a moderator role.',
code: 'ROLE_PERMISSION_DENIED',
+ kind: 'permission',
id: 'd33d5333-db36-423d-a8f9-1a2b9549da41',
});
}
@@ -285,6 +286,7 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError({
message: 'You are not assigned to an administrator role.',
code: 'ROLE_PERMISSION_DENIED',
+ kind: 'permission',
id: 'c3d38592-54c0-429d-be96-5636b0431a61',
});
}
@@ -296,6 +298,7 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError({
message: 'You are not assigned to a required role.',
code: 'ROLE_PERMISSION_DENIED',
+ kind: 'permission',
id: '7f86f06f-7e15-4057-8561-f4b6d4ac755a',
});
}
@@ -305,6 +308,7 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError({
message: 'Your app does not have the necessary permissions to use this endpoint.',
code: 'PERMISSION_DENIED',
+ kind: 'permission',
id: '1370e5b7-d4eb-4566-bb1d-7748ee6a1838',
});
}