diff --git a/app/api/apiclient.php b/app/api/apiclient.php index 24a0b7c..6abbcfb 100644 --- a/app/api/apiclient.php +++ b/app/api/apiclient.php @@ -252,7 +252,6 @@ function client_secret($id, $password){ function client_add_password($client_id, $password, $confirm, $minlen = 5){ - if ($password == ''){ return 'пароль не задан'; } @@ -268,11 +267,8 @@ function client_add_password($client_id, $password, $confirm, $minlen = 5){ $clientpassword = password_hash($password, PASSWORD_DEFAULT); $sqlupdate = "UPDATE `clients` SET `clientpassword` = '$clientpassword' WHERE `client_id` = '$client_id'"; - $result = db_get($sqlupdate, 'chitatel'); - - return ['newpassword' => $clientpassword]; } diff --git a/app/routes/auth.php b/app/routes/auth.php index f077f76..d4488b6 100644 --- a/app/routes/auth.php +++ b/app/routes/auth.php @@ -110,6 +110,100 @@ function test_client_hash_kuri($hash){ } + +function reminder_kuri(){ + + + if (isset($_POST['resetmail'])){ + + $resetmail = trim(mb_strtolower($_POST['resetmail'])); + + + $client = db_get("SELECT * FROM `clients` WHERE `clientmail` = '$resetmail' LIMIT 1"); + + + if (count($client) > 0 ) { + + $resetdate = date('Y-m-d G:i:s'); + + $items = array(); + $items['resetmail'] = $resetmail; + $items['client_id'] = $client['client_id']; + $items['resetdate'] = $resetdate; + $items['resetstatus'] = 0; + $items['resethash'] = md5($resetmail.$resetdate); + + $result = db_insert('resetpwd', $items, 'klan'); + + $link = SITE.'resetpassword/'.$items['resethash']; + + $tempcontent = VIEWPATH.'reminder_end.phtml'; + include VIEWPATH.'layout_lite.phtml'; //центральный шаблон + + } + + else { + $error = 'Адрес электронной почты не найден'; + $tempcontent = VIEWPATH.'reminder.phtml'; + include VIEWPATH.'layout_lite.phtml'; //центральный шаблон + } + + + + } + else { + $tempcontent = VIEWPATH.'reminder.phtml'; + include VIEWPATH.'layout_lite.phtml'; //центральный шаблон + } + +} + + +function resetpassword_kuri($hash){ + + $url = "/resetpassword/$hash"; + $minlen = 5; + + $resetsql = "SELECT * FROM `resetpwd` WHERE `resethash` = '$hash' AND `resetstatus` = '0' LIMIT 1"; + $resetclient = db_get($resetsql); + + if (count($resetclient) > 0){ + + if (isset($_POST['reset-submit'])){ + + $result = client_add_password($resetclient['client_id'], $_POST['new-password'], $_POST['confirm-password'], $minlen); + + if (isset($result['newpassword'])){ + + db_get("UPDATE `resetpwd` SET `resetstatus` = 1 WHERE `resetpwd_id` = ${$client['client_id']}"); + + add_user_cookie($client['client_id'], $result['newpassword']); + $linklab = SITE.'mybooks'; + $viewform = False; + } + + } + else { + $viewform = True; + } + + $tempcontent = VIEWPATH.'reset.phtml'; + include VIEWPATH.'layout_lite.phtml'; + } + + + + else { + echo 'неверная ссылка'; + return false; + } + + return True; + +} + + + // if(password_verify($_POST["password"],$hashed_password)) function resetpwd_kuri($hash){ diff --git a/app/views/login.phtml b/app/views/login.phtml index 9e397c0..8059f6b 100644 --- a/app/views/login.phtml +++ b/app/views/login.phtml @@ -4,7 +4,7 @@

-

забыли пароль

+

забыли пароль

diff --git a/app/views/noreset.phtml b/app/views/noreset.phtml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/reminder.phtml b/app/views/reminder.phtml new file mode 100644 index 0000000..264c4bb --- /dev/null +++ b/app/views/reminder.phtml @@ -0,0 +1,16 @@ +
+ +

Восстановление пароля

+ + +
+ + +
+ +

+

+
+ + +
\ No newline at end of file diff --git a/app/views/reminder_end.phtml b/app/views/reminder_end.phtml new file mode 100644 index 0000000..7c111c1 --- /dev/null +++ b/app/views/reminder_end.phtml @@ -0,0 +1,5 @@ +

Ссылка на восстановление пароля выслана на Вашу электронную почту

+ + +
Для установки пароля пройдите по ссылке
+ \ No newline at end of file