mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
[next] Email (#2261)
* feat: suspending, banning, now propogation * feat: added email rendering + localization support * fix: fix related to lib * refactor: moved juicer to queue task * refactor: cleanup of job processor * refactor: improved error messaging around failed email * feat: initial forgot passwor impl * fix: fixed rebase errors * feat: send back Content-Language header with requests * feat: added ban email * feat: implemented forgotten password API * fix: linting * feat: support more emails * fix: promise patches * feat: initial confirm email API * feat: added rate limiting * feat: added URL support * feat: added email docs * fix: updated docs * chore: documentation review * fix: fixed build bug * feat: implement forgot password in auth popup * test: add tests + fixes * chore: rename StatelessComponent to FunctionComponent * fix: types and test fixes * chore: upgrade deps * fix: THANK YOU TESTS FOR SAVING MY A** * chore: reorder imports * chore: remove obsolete ! * feat: implement accounts bundle * refactor: review suggestion * fix: rebase upgrade error * fix: rebase bug * feat: reset password link support * test: add tests for account password reset page * fix: remove redirect uri * fix: revert local state changes
This commit is contained in:
@@ -224,11 +224,31 @@ export class CommentBodyExceedsMaxLengthError extends TalkError {
|
||||
}
|
||||
}
|
||||
|
||||
export class URLInvalidError extends TalkError {
|
||||
constructor({
|
||||
url,
|
||||
...properties
|
||||
}: {
|
||||
url: string;
|
||||
tenantDomains: string[];
|
||||
tenantDomain?: string;
|
||||
}) {
|
||||
super({
|
||||
code: ERROR_CODES.URL_NOT_PERMITTED,
|
||||
context: { pvt: properties, pub: { url } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class StoryURLInvalidError extends TalkError {
|
||||
constructor(properties: { storyURL: string; tenantDomains: string[] }) {
|
||||
constructor(properties: {
|
||||
storyURL: string;
|
||||
tenantDomains: string[];
|
||||
tenantDomain?: string;
|
||||
}) {
|
||||
super({
|
||||
code: ERROR_CODES.STORY_URL_NOT_PERMITTED,
|
||||
context: { pub: properties },
|
||||
context: { pvt: properties },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -336,10 +356,11 @@ export class TokenNotFoundError extends TalkError {
|
||||
}
|
||||
|
||||
export class TokenInvalidError extends TalkError {
|
||||
constructor(token: string, reason: string) {
|
||||
constructor(token: string, reason: string, cause?: Error) {
|
||||
super({
|
||||
code: ERROR_CODES.TOKEN_INVALID,
|
||||
context: { pub: { token }, pvt: { reason } },
|
||||
cause,
|
||||
context: { pvt: { token, reason } },
|
||||
status: 401,
|
||||
});
|
||||
}
|
||||
@@ -366,7 +387,7 @@ export class UserForbiddenError extends TalkError {
|
||||
|
||||
export class UserNotFoundError extends TalkError {
|
||||
constructor(userID: string) {
|
||||
super({ code: ERROR_CODES.USER_NOT_FOUND, context: { pvt: { userID } } });
|
||||
super({ code: ERROR_CODES.USER_NOT_FOUND, context: { pub: { userID } } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,6 +415,15 @@ export class TenantNotFoundError extends TalkError {
|
||||
}
|
||||
}
|
||||
|
||||
export class IntegrationDisabled extends TalkError {
|
||||
constructor(integrationName: string) {
|
||||
super({
|
||||
code: ERROR_CODES.INTEGRATION_DISABLED,
|
||||
context: { pvt: { integrationName } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class InternalError extends TalkError {
|
||||
constructor(cause: Error, reason: string) {
|
||||
super({
|
||||
@@ -505,3 +535,35 @@ export class UserSuspended extends TalkError {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class PasswordResetTokenExpired extends TalkError {
|
||||
constructor(reason: string, cause?: Error) {
|
||||
super({
|
||||
code: ERROR_CODES.PASSWORD_RESET_TOKEN_EXPIRED,
|
||||
cause,
|
||||
status: 400,
|
||||
context: { pvt: { reason } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfirmEmailTokenExpired extends TalkError {
|
||||
constructor(reason: string, cause?: Error) {
|
||||
super({
|
||||
code: ERROR_CODES.EMAIL_CONFIRM_TOKEN_EXPIRED,
|
||||
cause,
|
||||
status: 400,
|
||||
context: { pvt: { reason } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class RateLimitExceeded extends TalkError {
|
||||
constructor(resource: string, max: number, tries: number) {
|
||||
super({
|
||||
code: ERROR_CODES.RATE_LIMIT_EXCEEDED,
|
||||
status: 429,
|
||||
context: { pvt: { resource, max, tries } },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ export const ERROR_TRANSLATIONS: Record<ERROR_CODES, string> = {
|
||||
STORY_CLOSED: "error-storyClosed",
|
||||
STORY_NOT_FOUND: "error-storyNotFound",
|
||||
STORY_URL_NOT_PERMITTED: "error-storyURLNotPermitted",
|
||||
URL_NOT_PERMITTED: "error-urlNotPermitted",
|
||||
TENANT_INSTALLED_ALREADY: "error-tenantInstalledAlready",
|
||||
TENANT_NOT_FOUND: "error-tenantNotFound",
|
||||
TOKEN_INVALID: "error-tokenInvalid",
|
||||
@@ -39,4 +40,8 @@ export const ERROR_TRANSLATIONS: Record<ERROR_CODES, string> = {
|
||||
USER_ALREADY_BANNED: "error-userAlreadyBanned",
|
||||
USER_BANNED: "error-userBanned",
|
||||
USER_SUSPENDED: "error-userSuspended",
|
||||
INTEGRATION_DISABLED: "error-integrationDisabled",
|
||||
PASSWORD_RESET_TOKEN_EXPIRED: "error-passwordResetTokenExpired",
|
||||
EMAIL_CONFIRM_TOKEN_EXPIRED: "error-emailConfirmTokenExpired",
|
||||
RATE_LIMIT_EXCEEDED: "error-rateLimitExceeded",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user