Использование базового TOTP через мобильное приложение вместо существующей реализации второго пароля на javascript.
This commit is contained in:
@@ -6,30 +6,24 @@ use Core\Config;
|
||||
use Core\Db;
|
||||
use Helper\Mail;
|
||||
use PassGen;
|
||||
use UserIp;
|
||||
|
||||
class Confirmation
|
||||
{
|
||||
/**
|
||||
* Для однотипных писем с подтверждением.
|
||||
* @param array $userinfo Данные из (User)->info.
|
||||
* @param mixed $value Новое значение
|
||||
* @param string $value Новое значение
|
||||
* @param ?int $code Проверочный код
|
||||
* @param string $type Тип меняемого значения. С маленькой буквы, именительный падеж.
|
||||
* @return void
|
||||
*/
|
||||
public static function byEmail(array $userinfo, string $type, $value, ?int $code = null)
|
||||
public static function byEmail(array $userinfo, string $type, string $value, ?int $code = null): void
|
||||
{
|
||||
if ($type === 'pass2' && is_null($code)) {
|
||||
self::pass2ByEmailCustom($userinfo, $value);
|
||||
return;
|
||||
}
|
||||
$ip = UserIp::get();
|
||||
$date = date('d.m.y H:i');
|
||||
$https = Config::get('https');
|
||||
$support = Config::get('support');
|
||||
$activationLink = 'https://' . $userinfo['city'] . Config::get('host') .
|
||||
"/confirm.php?id={$userinfo['id']}&code=$code";
|
||||
$activationLink = Config::get('https') . "/confirm.php?id={$userinfo['id']}&code=$code";
|
||||
$fulllogin = $userinfo['login'] . "[{$userinfo['level']}]";
|
||||
Mail::send(
|
||||
$userinfo['mail'],
|
||||
@@ -55,31 +49,7 @@ class Confirmation
|
||||
);
|
||||
}
|
||||
|
||||
private static function pass2ByEmailCustom(array $userinfo, string $pass2)
|
||||
{
|
||||
|
||||
$ip = UserIp::get();
|
||||
$fulllogin = $userinfo['login'] . "[{$userinfo['level']}]";
|
||||
Mail::send(
|
||||
$userinfo['mail'],
|
||||
<<<HTML
|
||||
<html lang="ru">
|
||||
<head><title>Второй пароль от персонажа $fulllogin.</title></head>
|
||||
<body>
|
||||
Вами, с IP адреса - $ip, был установлен второй пароль в игре Бойцовский Клуб.<br>
|
||||
Если это были не Вы, свяжитесь с администрацией сайта.<br><br>
|
||||
------------------------------------------------------------------<br>
|
||||
Ваш логин | {$userinfo['login']}<br>
|
||||
Второй пароль | ' . $pass2 . '<br>
|
||||
------------------------------------------------------------------<br>
|
||||
<br><br>Желаем Вам приятной игры.<br><br><i>Администрация</i>
|
||||
</body>
|
||||
HTML,
|
||||
"Второй пароль от персонажа $fulllogin"
|
||||
);
|
||||
}
|
||||
|
||||
public static function userRegistrationCodeByEmail(string $email, string $login)
|
||||
public static function userRegistrationCodeByEmail(string $email, string $login): void
|
||||
{
|
||||
$code = PassGen::intCode(4);
|
||||
Db::sql('insert into secure_code (email, code, time) values (?,?,unix_timestamp())', [$email, $code]);
|
||||
|
||||
Reference in New Issue
Block a user