mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-29 03:21:13 +00:00
TSK-568: User-friendly message on join for expired links (#2752)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
ea492902f1
commit
2401f0e6bc
@ -5,6 +5,7 @@
|
||||
"InvalidId": "Invalid Id: {id}",
|
||||
"BadRequest": "Bad request",
|
||||
"Forbidden": "Forbidden",
|
||||
"ExpiredLink": "This invite link is expired",
|
||||
"Unauthorized": "Unauthorized",
|
||||
"UnknownMethod": "Unknown method: {method}",
|
||||
"InternalServerError": "Internal server error"
|
||||
|
@ -5,8 +5,9 @@
|
||||
"InvalidId": "Некорректный Id: {id}",
|
||||
"BadRequest": "Некорректный запрос",
|
||||
"Forbidden": "Запрещено",
|
||||
"ExpiredLink": "Ссылка истекла",
|
||||
"Unauthorized": "Неавторизован",
|
||||
"UnknownMethod": "Неизвестный метод: {method}",
|
||||
"InternalServerError": "Внутренняя ошибка сервеа"
|
||||
"InternalServerError": "Внутренняя ошибка сервера"
|
||||
}
|
||||
}
|
||||
|
@ -141,6 +141,7 @@ export default plugin(platformId, {
|
||||
BadRequest: '' as StatusCode,
|
||||
Forbidden: '' as StatusCode,
|
||||
Unauthorized: '' as StatusCode,
|
||||
ExpiredLink: '' as StatusCode,
|
||||
UnknownMethod: '' as StatusCode<{ method: string }>,
|
||||
InternalServerError: '' as StatusCode
|
||||
},
|
||||
|
@ -279,7 +279,7 @@ export async function checkInvite (invite: Invite | null, email: string): Promis
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
||||
}
|
||||
if (invite.exp < Date.now()) {
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.ExpiredLink, {}))
|
||||
}
|
||||
if (!new RegExp(invite.emailMask).test(email)) {
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
||||
@ -924,6 +924,11 @@ function wrap (f: (db: Db, productId: string, ...args: any[]) => Promise<any>):
|
||||
.then((result) => ({ id: request.id, result }))
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
if (err.status.code === platform.status.ExpiredLink) {
|
||||
return {
|
||||
error: new Status(Severity.ERROR, platform.status.ExpiredLink, {})
|
||||
}
|
||||
}
|
||||
return {
|
||||
error:
|
||||
err instanceof PlatformError
|
||||
|
Loading…
Reference in New Issue
Block a user