finished reset password & other changes

This commit is contained in:
2024-04-24 22:37:55 +03:00
parent b1ad7b5c3e
commit 53cadc289a
58 changed files with 1520 additions and 349 deletions

View File

@@ -1,11 +1,13 @@
import { locales } from '@/config/locales'
import { UUID_V4_REGEX } from '@/config/validation'
export const USER_PROFILE_URL: string = '/cabinet'
export const AUTH_LOGIN_URL: string = '/auth/login'
export const AUTH_REGISTER_URL: string = '/auth/register'
export const AUTH_ERROR_URL: string = '/auth/error'
export const AUTH_USER_VERIFICATION_URL: string = '/auth/user-verification/'
export const AUTH_URL: string = '/auth/'
export const AUTH_LOGIN_URL: string = `${AUTH_URL}login`
export const AUTH_REGISTER_URL: string = `${AUTH_URL}register`
export const AUTH_RESET_PASSWORD_URL: string = `${AUTH_URL}reset`
export const AUTH_ERROR_URL: string = `${AUTH_URL}error`
export const AUTH_USER_VERIFICATION_URL: string = `${AUTH_URL}user-verification`
export const AUTH_NEW_PASSWORD_URL: string = `${AUTH_URL}new-password`
/**
* An array of routes that accessible to the public.
@@ -13,7 +15,7 @@ export const AUTH_USER_VERIFICATION_URL: string = '/auth/user-verification/'
* @type {string[]}
*/
export const publicRoutes: string[] = [
'/', '/about', `${AUTH_USER_VERIFICATION_URL}${UUID_V4_REGEX}`]
'/', '/((about)(|/.*))', `(${AUTH_USER_VERIFICATION_URL}|${AUTH_NEW_PASSWORD_URL})/${UUID_V4_REGEX}`]
/**
* An array of routes that are used for authentication.
@@ -21,7 +23,11 @@ export const publicRoutes: string[] = [
* @type {string[]}
*/
export const authRoutes: string[] = [
AUTH_LOGIN_URL, AUTH_REGISTER_URL, AUTH_ERROR_URL]
AUTH_LOGIN_URL, AUTH_REGISTER_URL, AUTH_ERROR_URL, AUTH_RESET_PASSWORD_URL]
export const authRoutesRegEx = [
AUTH_URL + '(' +
authRoutes.map((uri: string) => uri.replace(AUTH_URL, '')).join('|') + ')']
/**
* The prefix for API authentication routes.
@@ -36,9 +42,3 @@ export const apiAuthPrefix: string = '/api/auth'
*/
export const DEFAULT_LOGIN_REDIRECT: string = USER_PROFILE_URL
export const testPathnameRegex = (
pages: string[], pathName: string): boolean => {
const pattern: string = `^(/(${locales.join('|')}))?(${pages.flatMap(
(p) => (p === '/' ? ['', '/'] : p)).join('|')})/?$`
return RegExp(pattern, 'is').test(pathName)
}