mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 00:09:34 +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}",
|
"InvalidId": "Invalid Id: {id}",
|
||||||
"BadRequest": "Bad request",
|
"BadRequest": "Bad request",
|
||||||
"Forbidden": "Forbidden",
|
"Forbidden": "Forbidden",
|
||||||
|
"ExpiredLink": "This invite link is expired",
|
||||||
"Unauthorized": "Unauthorized",
|
"Unauthorized": "Unauthorized",
|
||||||
"UnknownMethod": "Unknown method: {method}",
|
"UnknownMethod": "Unknown method: {method}",
|
||||||
"InternalServerError": "Internal server error"
|
"InternalServerError": "Internal server error"
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
"InvalidId": "Некорректный Id: {id}",
|
"InvalidId": "Некорректный Id: {id}",
|
||||||
"BadRequest": "Некорректный запрос",
|
"BadRequest": "Некорректный запрос",
|
||||||
"Forbidden": "Запрещено",
|
"Forbidden": "Запрещено",
|
||||||
|
"ExpiredLink": "Ссылка истекла",
|
||||||
"Unauthorized": "Неавторизован",
|
"Unauthorized": "Неавторизован",
|
||||||
"UnknownMethod": "Неизвестный метод: {method}",
|
"UnknownMethod": "Неизвестный метод: {method}",
|
||||||
"InternalServerError": "Внутренняя ошибка сервеа"
|
"InternalServerError": "Внутренняя ошибка сервера"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,7 @@ export default plugin(platformId, {
|
|||||||
BadRequest: '' as StatusCode,
|
BadRequest: '' as StatusCode,
|
||||||
Forbidden: '' as StatusCode,
|
Forbidden: '' as StatusCode,
|
||||||
Unauthorized: '' as StatusCode,
|
Unauthorized: '' as StatusCode,
|
||||||
|
ExpiredLink: '' as StatusCode,
|
||||||
UnknownMethod: '' as StatusCode<{ method: string }>,
|
UnknownMethod: '' as StatusCode<{ method: string }>,
|
||||||
InternalServerError: '' as StatusCode
|
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, {}))
|
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
||||||
}
|
}
|
||||||
if (invite.exp < Date.now()) {
|
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)) {
|
if (!new RegExp(invite.emailMask).test(email)) {
|
||||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
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 }))
|
.then((result) => ({ id: request.id, result }))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
if (err.status.code === platform.status.ExpiredLink) {
|
||||||
|
return {
|
||||||
|
error: new Status(Severity.ERROR, platform.status.ExpiredLink, {})
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
error:
|
error:
|
||||||
err instanceof PlatformError
|
err instanceof PlatformError
|
||||||
|
Loading…
Reference in New Issue
Block a user