because I got bored of customising my CV for every job
at main 106 lines 2.7 kB view raw
1import { DomainError } from "./app-error"; 2import { AuthenticationErrorCode } from "./error-codes"; 3 4export abstract class AuthenticationError extends DomainError {} 5 6export class NoTokenError extends AuthenticationError { 7 constructor() { 8 super(AuthenticationErrorCode.NO_TOKEN, "No authentication token provided"); 9 } 10} 11 12export class InvalidCredentialsError extends AuthenticationError { 13 constructor() { 14 super(AuthenticationErrorCode.INVALID_CREDENTIALS, "Invalid credentials"); 15 } 16} 17 18export class InvalidTokenError extends AuthenticationError { 19 constructor() { 20 super(AuthenticationErrorCode.INVALID_TOKEN, "Invalid token"); 21 } 22} 23 24export class TokenExpiredError extends AuthenticationError { 25 constructor() { 26 super(AuthenticationErrorCode.TOKEN_EXPIRED, "Token expired"); 27 } 28} 29 30export class InvalidRefreshTokenError extends AuthenticationError { 31 constructor() { 32 super( 33 AuthenticationErrorCode.INVALID_REFRESH_TOKEN, 34 "Invalid or expired refresh token", 35 ); 36 } 37} 38 39export class CurrentPasswordIncorrectError extends AuthenticationError { 40 constructor() { 41 super( 42 AuthenticationErrorCode.CURRENT_PASSWORD_INCORRECT, 43 "Current password is incorrect", 44 ); 45 } 46} 47 48export class PasswordIncorrectError extends AuthenticationError { 49 constructor() { 50 super(AuthenticationErrorCode.PASSWORD_INCORRECT, "Password is incorrect"); 51 } 52} 53 54export class EmailAlreadyVerifiedError extends AuthenticationError { 55 constructor() { 56 super( 57 AuthenticationErrorCode.EMAIL_ALREADY_VERIFIED, 58 "Email is already verified", 59 ); 60 } 61} 62 63export class InvalidVerificationTokenError extends AuthenticationError { 64 constructor() { 65 super( 66 AuthenticationErrorCode.INVALID_VERIFICATION_TOKEN, 67 "Invalid verification token", 68 ); 69 } 70} 71 72export class VerificationTokenExpiredError extends AuthenticationError { 73 constructor() { 74 super( 75 AuthenticationErrorCode.VERIFICATION_TOKEN_EXPIRED, 76 "Verification token has expired", 77 ); 78 } 79} 80 81export class InvalidPasswordResetTokenError extends AuthenticationError { 82 constructor() { 83 super( 84 AuthenticationErrorCode.INVALID_PASSWORD_RESET_TOKEN, 85 "Invalid password reset token", 86 ); 87 } 88} 89 90export class PasswordResetTokenExpiredError extends AuthenticationError { 91 constructor() { 92 super( 93 AuthenticationErrorCode.PASSWORD_RESET_TOKEN_EXPIRED, 94 "Password reset token has expired", 95 ); 96 } 97} 98 99export class EmailNotVerifiedError extends AuthenticationError { 100 constructor() { 101 super( 102 AuthenticationErrorCode.EMAIL_NOT_VERIFIED, 103 "Email address has not been verified. Please check your email and verify your account before logging in.", 104 ); 105 } 106}