57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
const errors: Record<string, [number, string]> = {
|
|
banned: [401, 'User is banned.'],
|
|
blocked: [401, 'User is blocked due to too many login attempts.'],
|
|
duplicateEmail: [409, 'The email has already been registered'],
|
|
emailNotVerified: [401, "This account's email has not been verified"],
|
|
missingParameters: [422, 'Oh no missing stuff'],
|
|
noUserFound: [400, 'No user registered with that email.'],
|
|
notAuthorized: [401, 'The email is not authorized to create an account'],
|
|
tokenConsumed: [410, 'Token already consumed'],
|
|
tokenExpired: [410, 'Token expired'],
|
|
tokenNotFound: [404, 'Token not found'],
|
|
tokenNotLatest: [410, 'Newer token has been issued'],
|
|
tooManyLoginAttempts: [401, 'Too many failed login attempts'],
|
|
wrongPassword: [401, 'Wrong password'],
|
|
}
|
|
|
|
const paths = {
|
|
changePassword: '/admin/change-password',
|
|
forgotPassword: '/admin/forgot-password',
|
|
login: '/admin/login',
|
|
register: '/admin/register',
|
|
}
|
|
|
|
const maxLoginAttempts = 5
|
|
|
|
const requireVerification = true
|
|
|
|
const redirects = {
|
|
login: '/admin/',
|
|
logout: '/admin/login',
|
|
register: '/admin/login',
|
|
}
|
|
|
|
const remember = {
|
|
// if expires is defined, it will be used. otherwise maxage
|
|
expires: new Date('2038-01-19T03:14:07.000Z'),
|
|
maxAge: 10 * 365 * 24 * 60 * 60 * 1000,
|
|
}
|
|
|
|
const timeouts = {
|
|
invite: 30 * 24 * 60 * 60 * 1000,
|
|
// 1 day
|
|
changePassword: 24 * 60 * 60 * 1000,
|
|
// verify email
|
|
verifyEmail: 7 * 24 * 60 * 60 * 1000,
|
|
}
|
|
|
|
export default {
|
|
errors,
|
|
paths,
|
|
redirects,
|
|
maxLoginAttempts,
|
|
requireVerification,
|
|
remember,
|
|
timeouts,
|
|
}
|