Регистрация
Фронт (стили+страница), полировка стр. логина, микроправки и микрооптимизации
This commit is contained in:
@@ -63,7 +63,7 @@ function User_Create_Method (array $req): ReturnT {
|
||||
|
||||
// Input sanity checks
|
||||
|
||||
// If registration turned off
|
||||
// If registration is turned off
|
||||
if (!$Config["registration"]["active"])
|
||||
return new ReturnT(err_code: E_AUT_REGCLOSED);
|
||||
|
||||
@@ -77,8 +77,8 @@ function User_Create_Method (array $req): ReturnT {
|
||||
$password = $req["password"];
|
||||
|
||||
// If password is too weak
|
||||
if (strlen($password) < 8)
|
||||
return new ReturnT(err_code: E_AUT_PWD2WEAK);
|
||||
if (strlen($password) < $Config["registration"]["min_passw_len"])
|
||||
return new ReturnT(err_code: E_AUT_PWD2WEAK, err_desc: "password must contain at least " . strval($Config["registration"]["min_passw_len"]) . " characters");
|
||||
|
||||
// If we need email but it isnt supplied
|
||||
if ($Config["registration"]["need_email"] && !isset($req["email"])) {
|
||||
@@ -95,13 +95,13 @@ function User_Create_Method (array $req): ReturnT {
|
||||
} elseif (isset($req["invite_id"])) {
|
||||
// TODO: check invite and reject if it invalid
|
||||
//$invite_id = $req["invite_id"];
|
||||
return new ReturnT(err_code: E_UNS_NOTIMPL, err_desc: "invitations are not implemented");
|
||||
return new ReturnT(err_code: E_UNS_NOTIMPL, err_desc: "invitations are not implemented yet");
|
||||
}
|
||||
|
||||
// Check login and password for pattern match
|
||||
$preg_str = "/[^" . $Config["registration"]["allowed_syms"] . "]/";
|
||||
if (preg_match($preg_str, $login) || preg_match($preg_str, $password))
|
||||
return new ReturnT(err_code: E_UIN_BADARGS, err_desc: "only allowed symbols are: " . $Config["registration"]["allowed_syms"]);
|
||||
return new ReturnT(err_code: E_UIN_BADARGS, err_desc: "only allowed symbols in login and password are: " . $Config["registration"]["allowed_syms"]);
|
||||
|
||||
// Check if login already exists
|
||||
if (User_LoginExist($login))
|
||||
|
@@ -43,7 +43,7 @@ function User_Login_Method (array $req): ReturnT {
|
||||
return new ReturnT(err_code: E_AUT_WRONGCREDS, err_desc: "you must supply both login and password");
|
||||
|
||||
// Checking if password is correct
|
||||
$s = $db->prepare("SELECT * FROM users WHERE login = ?");
|
||||
$s = $db->prepare("SELECT id,password_hash,salt FROM users WHERE login = ?");
|
||||
$s->bind_param("s", $login);
|
||||
$s->execute();
|
||||
$d = $s->get_result()->fetch_assoc();
|
||||
|
Reference in New Issue
Block a user