Skip to content

Commit

Permalink
@ F Created validate_password function
Browse files Browse the repository at this point in the history
- Will be used for validating passwords on server side
  • Loading branch information
TheRealFakeAdmin committed Mar 19, 2024
1 parent 5b6afee commit d787b88
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions csb/csb-accounts/auth-login-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,30 @@ function insertUserSession($db, $user) {
}
return $ret;
}

/**
* Checks password strength
*/
function validate_password(string $password, string $confirm_password) {
if(!empty($password) && ($password == $confirm_password)) {
$password = test_input($password);
$confirm_password = test_input($confirm_password);
if (strlen($password) <= '8') {
$passwordErr = "Your Password Must Contain At Least 8 Characters!";
}
elseif(!preg_match("#[0-9]+#",$password)) {
$passwordErr = "Your Password Must Contain At Least 1 Number!";
}
elseif(!preg_match("#[A-Z]+#",$password)) {
$passwordErr = "Your Password Must Contain At Least 1 Capital Letter!";
}
elseif(!preg_match("#[a-z]+#",$password)) {
$passwordErr = "Your Password Must Contain At Least 1 Lowercase Letter!";
}
}
elseif(!empty($password)) {
$cpasswordErr = "Please Check You've Entered Or Confirmed Your Password!";
} else {
$passwordErr = "Please enter password ";
}
}

0 comments on commit d787b88

Please sign in to comment.