feat: implement identity and security features
- Added account types and privileged account types constants. - Created admin user controller for updating user security fields. - Developed role assignment controller for managing user roles. - Implemented validation middleware for request schemas. - Defined user role and auth session models for database interactions. - Created services for authentication, email notifications, and OTP handling. - Developed OAuth service for Google and Apple authentication. - Added JWT utility functions for token generation and verification. - Implemented comprehensive tests for authentication, session management, and password policies. - Created migration for updating user schema and adding new tables for auth sessions and user identities.
This commit is contained in:
@@ -1,32 +1,5 @@
|
||||
//app/utils/validation/validatePassword.util.js
|
||||
const validatePassword = (password) => {
|
||||
// Check if password is a string
|
||||
if (typeof password !== "string") {
|
||||
return false;
|
||||
}
|
||||
const { passwordSchema } = require("../../validation/auth.schemas");
|
||||
|
||||
// At least 1 uppercase letter
|
||||
const hasUppercase = /[A-Z]/.test(password);
|
||||
const validatePassword = (password) => passwordSchema.safeParse(password).success;
|
||||
|
||||
// At least 1 lowercase letter
|
||||
const hasLowercase = /[a-z]/.test(password);
|
||||
|
||||
// At least 1 symbol
|
||||
const hasSymbol = /[^A-Za-z0-9]/.test(password);
|
||||
|
||||
// At least 4 numbers
|
||||
const numberCount = (password.match(/[0-9]/g) || []).length;
|
||||
|
||||
const hasFourNumbers = numberCount >= 4;
|
||||
|
||||
return (
|
||||
hasUppercase &&
|
||||
hasLowercase &&
|
||||
hasSymbol &&
|
||||
hasFourNumbers
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validatePassword,
|
||||
};
|
||||
module.exports = { validatePassword };
|
||||
|
||||
Reference in New Issue
Block a user