From 603f1fd96f3459b58f0af1466f9c9d0c2a348935 Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Sun, 10 May 2020 12:14:54 +0300 Subject: [PATCH] add client_add_password --- app/api/apiclient.php | 46 +++++++++++++++++++++++++++++++++++++++++++ app/confg.php | 4 ++-- app/routes/auth.php | 26 ++++++++++++++++++++++++ app/views/reset.phtml | 10 ++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 app/views/reset.phtml diff --git a/app/api/apiclient.php b/app/api/apiclient.php index c08964c..de6949e 100644 --- a/app/api/apiclient.php +++ b/app/api/apiclient.php @@ -54,6 +54,52 @@ function clientbuys_kuri($client_id, $page = 1){ +function client_find_email($email){ + + $pwd_query = "SELECT * FROM `clients` WHERE `clientmail` = '$mail' LIMIT 1"; + $client = db_get($pwd_query); + + if (isset($client['client_id'])) + return $client; + else + return false; + +} + +function client_add_password($mail, $pwd, $pwd2){ + + $maxlen = 5; + + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) + return 'некорректный email'; + + $find = client_find_email($email); + if ($find) + return 'email не найден'; + + if ($pwd == ''){ + return 'пароль не задан'; + } + + if (strlen($pwd) < $maxlen) { + return "пароль должен быть не менее $maxlen символов"; + } + + if ($pwd == $pwd2){ + return "пароли не совпадают"; + } + + $clientpassword = password_hash($pwd); + $sqlupdate = "UPDATE `clients` SET `clientpassword` = '$clientpassword' WHERE `clientmail` = '$mail'"; + + dbl_get($sqlupdate); + + return True; + +} + + + function clientmail($mail, $hash){ $client = db_get("SELECT * FROM `clients` WHERE `clientmail` = $mail LIMIT 1"); diff --git a/app/confg.php b/app/confg.php index 4149c6f..e774527 100644 --- a/app/confg.php +++ b/app/confg.php @@ -1,7 +1,7 @@ "> +

Придумайте пароль не менее 5 символов

+

Пароль:

+

Повторить:

+ + + + +
+ \ No newline at end of file