[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:
Wyatt Johnson
2019-05-09 22:54:56 +02:00
committed by Kiwi
parent 945bd7f2b0
commit df57b4eb17
487 changed files with 6794 additions and 2431 deletions
+67 -5
View File
@@ -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 } },
});
}
}
+5
View File
@@ -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",
};