Example #1
0
 public function ajaxChangeProfile()
 {
     extract($_POST['input']);
     $data = \Models\User::checkUserPassword($_SESSION['auth']['id'], sha1($old_password));
     if (isset($data['id'])) {
         $user = \Models\User::changePassword($_SESSION['auth']['id'], sha1($new_password));
         if (isset($user['id'])) {
             return true;
         }
     } else {
         return false;
     }
 }
Example #2
0
 public function ajaxCheckUserEmailForRecovery()
 {
     if (isset($_POST['email'])) {
         $user = \Models\User::getUserByEmail($_POST['email']);
         if (!isset($user['id'])) {
             echo "This email is not registrated.";
         } else {
             $password = rand(100000, 999999);
             $data = \Models\User::changePassword($user['id'], sha1($password));
             if (isset($data['id'])) {
                 $subject = 'Password confirmation';
                 $body = "Your temporary password is: " . $password . " Please, change it after authentication in your profile.";
                 $result = Mailer::send($user['email'], $subject, $body);
                 if ($result == 'Message has been sent') {
                     echo $result;
                 }
             }
         }
     }
 }