This commit is contained in:
Билай Станислав 2024-12-05 14:38:36 +03:00
parent 8df13569e2
commit 9e446563b2

View File

@ -75,11 +75,11 @@ class SecureController extends AdminController
$loginForm = new LoginEmailForm(); $loginForm = new LoginEmailForm();
$loginForm->load($_REQUEST); $loginForm->load($_REQUEST);
$email = $loginForm->getItem("email"); $email = $loginForm->getItem("email");
$code = mt_rand(100000, 999999);
$user = $this->userService->getByField('email', $email); $user = $this->userService->getByField('email', $email);
if (!$user){ if (!$user){
$newUser = new User(); $newUser = new User();
$code = mt_rand(100000, 999999);
$newUser->email = $email; $newUser->email = $email;
$newUser->username = substr($email, 0, strpos($email, "@")); $newUser->username = substr($email, 0, strpos($email, "@"));
$newUser->password_hash = password_hash(md5(microtime() . bin2hex(random_bytes(10)) . time()), PASSWORD_DEFAULT); $newUser->password_hash = password_hash(md5(microtime() . bin2hex(random_bytes(10)) . time()), PASSWORD_DEFAULT);
@ -87,7 +87,6 @@ class SecureController extends AdminController
$newUser->auth_code_expires_at = date("Y-m-d H:i:s", strtotime("+5 minutes")); $newUser->auth_code_expires_at = date("Y-m-d H:i:s", strtotime("+5 minutes"));
$newUser->save(); $newUser->save();
} else { } else {
$code = mt_rand(100000, 999999);
$user->auth_code = $code; $user->auth_code = $code;
$user->auth_code_expires_at = date("Y-m-d H:i:s", strtotime("+5 minutes")); $user->auth_code_expires_at = date("Y-m-d H:i:s", strtotime("+5 minutes"));
$user->save(); $user->save();