public function testIsValidGuid()
 {
     $this->assertTrue(ForgotPassword::isValidGuid(String::UUID()), 'Valid input was not handled correctly.');
     $this->assertFalse(ForgotPassword::isValidGuid(null), 'Invalid input was not handled correctly.');
     $this->assertFalse(ForgotPassword::isValidGuid(-1), 'Invalid input was not handled correctly.');
     $this->assertFalse(ForgotPassword::isValidGuid(1), 'Invalid input was not handled correctly.');
     $this->assertFalse(ForgotPassword::isValidGuid('sdafrgsg'), 'Invalid input was not handled correctly.');
     $this->assertFalse(ForgotPassword::isValidGuid(array()), 'Invalid input was not handled correctly.');
 }
 public function emailDetail($LoginDetails)
 {
     try {
         $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
         $sql = "SELECT * FROM user_login WHERE email='" . $LoginDetails->getEmail() . "'";
         $isValidating = mysqli_query($this->con, $sql);
         $count = mysqli_num_rows($isValidating);
         if ($count == 1) {
             //$this->data = "VALID_EMAIL";
             $resetPassword = new ForgotPassword();
             $this->data = $resetPassword->GenarateRandomNo($LoginDetails->getEmail());
         } else {
             $this->data = "INVALID_EMAIL";
         }
     } catch (Exception $e) {
         echo 'SQL Exception: ' . $e->getMessage();
     }
     return $this->data;
 }
 public function __sendPassword($email)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     if (!empty($email) || !$email) {
         $select = $DB->sql_like('email', ':email', false, true, false, '|') . " AND mnethostid = :mnethostid AND deleted=0 AND suspended=0";
         $params = array('email' => $DB->sql_like_escape($email, '|'), 'mnethostid' => $CFG->mnet_localhost_id);
         $user = $DB->get_record_select('user', $select, $params, '*', IGNORE_MULTIPLE);
         if ($user and ($user->auth === 'nologin' or !is_enabled_auth($user->auth))) {
             // bad luck - user is not able to login, do not let them reset password
             $user = false;
             $response->response(true, 'fp_nologin');
             die;
         }
         if (!empty($user)) {
             if (is_mnet_remote_user($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Forgot password - mnet user trying to access.', 0, $user->id);
                 $response->response(true, 'cp_mnet_user');
                 die;
             }
             if (isguestuser($user)) {
                 add_to_log(-1, 'custom_webservice', 'guest_user', null, 'Forgot password - guest user credential supplied.', 0, $user->id);
                 $response->response(true, 'fp_guest');
                 die;
             }
             // make sure user is allowed to change password
             require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
             if (!ForgotPassword::__app_reset_password_and_mail($user)) {
                 add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Forgot password - email triggering failure.', 0, $user->id);
                 $response->response(true, 'fp_email_failure');
             } else {
                 set_user_preference('auth_forcepasswordchange', true, $user->id);
                 $response->response(true, 'fp_email_success');
             }
         } else {
             $response->response(false, 'fp_no_record');
         }
     } else {
         add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Forgot password - input parameters missing.', 0, $user->id);
     }
 }
Exemple #4
0
 /**
  * Generate or complete a forgot password request.
  *
  * @param string $guid The id of the request, may be null.
  */
 public function forgotPassword($guid = null)
 {
     if ($guid != null) {
         if (!ForgotPassword::isValidGuid($guid)) {
             $guid = null;
         }
     }
     $this->set('createRequest', $guid == null);
     if ($this->request->is('post')) {
         try {
             if ($guid == null) {
                 $data = $this->Member->createForgotPassword($this->request->data);
                 if ($data != false) {
                     $this->_sendEmail($data['email'], 'Password Reset Request', 'forgot_password', array('id' => $data['id']));
                     return $this->redirect(array('controller' => 'pages', 'action' => 'forgot_password_sent'));
                 } else {
                     return $this->redirect(array('controller' => 'pages', 'action' => 'home'));
                 }
             } else {
                 if ($this->Member->completeForgotPassword($guid, $this->request->data)) {
                     $this->Session->setFlash('Password successfully set.');
                     return $this->redirect(array('controller' => 'members', 'action' => 'login'));
                 } else {
                     $this->Session->setFlash('Unable to set password');
                     return $this->redirect(array('controller' => 'pages', 'action' => 'forgot_password_error'));
                 }
             }
         } catch (InvalidStatusException $e) {
             return $this->redirect(array('controller' => 'pages', 'action' => 'home'));
         }
     }
 }
Exemple #5
0
 public function actionForgotpassword()
 {
     $this->layout = '/layouts/login';
     $model = new ForgotPassword();
     if (isset($_POST['ForgotPassword'])) {
         $model->attributes = $_POST['ForgotPassword'];
         if ($model->validate()) {
             $user = User::model()->find('LOWER(u_email)=:email', array(':email' => strtolower($model->username)));
             $salt = md5(uniqid(rand(), true));
             $username = $user->u_username;
             $request = array('{reset_link}' => $salt, '{username}' => $username);
             if ($this->sendEmail(2, $user->u_email, $request)) {
                 if ($user->updateByPk($user->u_id, array('u_scrkey' => $salt))) {
                     Yii::app()->user->setFlash('success', 'A link has been sent to your email address to reset the password.');
                     $this->redirect(array('site/login'));
                 } else {
                     Yii::app()->user->setFlash('success', 'Error in setting the reset key.');
                 }
             }
         }
     }
     $this->render('forgotpassword', array('model' => $model));
 }
Exemple #6
0
 private function __forgot_password()
 {
     require_once 'clinique_forgot_password.php';
     $email = required_param('email', PARAM_EMAIL);
     ForgotPassword::__sendPassword($email);
 }
Exemple #7
0
 public function actionForgotPassword()
 {
     $model = new ForgotPassword();
     $getEmail = $_POST['ForgotPassword']['email'];
     $getModel = ServiceUser::model()->findByAttributes(array('email' => $getEmail));
     $gtModel = CustomerUser::model()->findByAttributes(array('email' => $getEmail));
     if (isset($_POST['ForgotPassword'])) {
         $model->attributes = $_POST['ForgotPassword'];
         if ($model->validate()) {
             if (!empty($getModel)) {
                 $p = rand();
                 $pwd = md5($p);
                 $subject = 'Welcome to Wow Cleans';
                 $body = $this->renderPartial('registrationEmail', array('model' => $model, 'password' => $p), true);
                 $getModel->password = $pwd;
                 if ($getModel->save()) {
                     $msg = Yii::app()->user->setFlash('serviceforgot', "Please check you email !");
                     Yii::app()->mailer->send($model->email, $subject, $body);
                     $this->redirect(array('registration/registration/index'));
                 }
             }
             if (!empty($gtModel)) {
                 $p = rand();
                 $pwd = md5($p);
                 $subject = 'Welcome to Wow Cleans';
                 $body = $this->renderPartial('registrationEmail', array('model' => $model, 'password' => $p), true);
                 $gtModel->password = $pwd;
                 if ($gtModel->save()) {
                     Yii::app()->mailer->send($model->email, $subject, $body);
                     Yii::app()->user->setFlash('forgotc', "Please check you email");
                     $this->redirect(array('registration/registration/index'));
                 }
             }
         } else {
             $errors = $model->getErrors();
         }
     }
     $links = CmsPages::model()->findAll();
     Yii::app()->params['MyArray'] = $links;
     $this->render('forgotpassword', array('model' => $model));
 }
Exemple #8
0
 /**
  * Complete a forgot password request
  *
  * @param string $guid The id of the forgot password request.
  * @param array $data Array of data containing the user submitted e-mail.
  * @return bool True if password was changed, false otherwise.
  */
 public function completeForgotPassword($guid, $data)
 {
     if (!ForgotPassword::isValidGuid($guid)) {
         return false;
     }
     // Need some extra validation
     $forgotPasswordModel = ClassRegistry::init('ForgotPassword');
     if (!isset($data) || !is_array($data)) {
         return false;
     }
     if ((isset($data['ForgotPassword']) && isset($data['ForgotPassword']['email']) && isset($data['ForgotPassword']['new_password']) && isset($data['ForgotPassword']['new_password_confirm'])) == false) {
         return false;
     }
     $forgotPasswordModel->set($data);
     if ($forgotPasswordModel->validates()) {
         $emailAddress = Hash::get($data, 'ForgotPassword.email');
         $memberInfo = $this->find('first', array('conditions' => array('Member.email' => $emailAddress), 'fields' => array('Member.member_id')));
         if ($memberInfo) {
             $memberId = $this->getIdForMember($memberInfo);
             if ($memberId > 0 && $forgotPasswordModel->isEntryValid($guid, $memberId)) {
                 $username = $this->getUsernameForMember($memberId);
                 if ($username) {
                     $password = Hash::get($data, 'ForgotPassword.new_password');
                     $dataSource = $this->getDataSource();
                     $dataSource->begin();
                     if ($this->__setPassword($username, $password, true) && $forgotPasswordModel->expireEntry($guid)) {
                         $dataSource->commit();
                         return true;
                     }
                     $dataSource->rollback();
                     return false;
                 }
             }
         }
     }
     return false;
 }
 public function forgotPasswordIsOfValidAge(ForgotPassword $toCheck)
 {
     $period = $this->getForgotPasswordTimePeriod();
     $requestDate = clone $toCheck->getRequestDate();
     $currentTime = new DateTime();
     $validTill = $requestDate->add(DateInterval::createFromDateString($period . ' minutes'));
     if ($currentTime >= $validTill) {
         return false;
     }
     return true;
 }
Exemple #10
0
        $user = $_GET['username'];
        $pass = $_GET['password'];
        $mail = $_GET['email'];
        $signupUser = new Signup($user, $pass, $mail);
        $signupUser->submit();
    } else {
        // load sign up page
        $signupPage = new signupPage();
        $signupPage->loadSignupPage();
    }
} else {
    if ($forgotpassword == 1) {
        require "forgotpassword.php";
        if (isset($_GET['username'])) {
            $user = $_GET['username'];
            $fpUser = new ForgotPassword($user);
            $fpUser->submit();
        } else {
            $fpPage = new ForgotPasswordPage();
            $fpPage->loadForgotPasswordPage();
        }
    } else {
        if ($login == 1) {
            require "login.php";
        } else {
            if ($deviceinfo == 1) {
                require "deviceinfo.php";
                $deviceInfo = new DeviceInfo();
                $deviceInfo->getDeviceInfo();
            } else {
                if ($view) {
<?php

include_once '../AutoLoader.php';
AutoLoader::registerDirectory('../src/classes');
require "config.php";
require "MailFiles/PHPMailerAutoload.php";
$fp = new ForgotPassword();
if (!empty($_POST)) {
    // Check if the email is recognized.
    $fp->checkEmail($_POST['email'], $db);
    // If the email was recognized, generate a new password and send an email.
    if (empty($fp->noEmail) && !empty($_POST['challenge_question_answer'])) {
        if ($fp->checkAnswer(htmlspecialchars($_POST['challenge_question_answer']))) {
            $newPassword = PasswordUtils::generateNewPassword();
            if ($fp->sendNewPassword($newPassword)) {
                $fp->success = "An email has been sent to the address that you provided. " . "Use the password included in the email to log in.";
                // Hash the new password and update the tables.
                $newSalt = PasswordUtils::generatePasswordSalt();
                $newPassword = PasswordUtils::hashPassword($newPassword, $newSalt);
                $fp->updateTables($newPassword, $newSalt, $db);
            } else {
                $fp->registrationFailure = "Verification email could not be sent. Please try again later.";
            }
        }
    }
}
?>

<!doctype html>
<html lang="en">
<head>
<?php

include_once '../AutoLoader.php';
AutoLoader::registerDirectory('../src/classes');
require "config.php";
require "MailFiles/PHPMailerAutoload.php";
$fp = new ForgotPassword();
if (!empty($_POST)) {
    // Check if the email is recognized.
    $fp->checkEmail($_POST['email'], $db);
    // If the email was recognized, generate a new password and send an email.
    if (empty($fp->noEmail)) {
        $newPassword = PasswordUtils::generateNewPassword();
        if ($fp->sendNewPassword($newPassword)) {
            $fp->success = "An email has been sent to the address that you provided. " . "Use the password included in the email to log in.";
            // Hash the new password and update the tables.
            $newSalt = PasswordUtils::generatePasswordSalt();
            $newPassword = PasswordUtils::hashPassword($newPassword, $newSalt);
            $fp->updateTables($newPassword, $newSalt, $db);
        } else {
            $fp->registrationFailure = "Password reset failed. Please try again later.";
        }
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Conference Room</title>
            $response['code'] = 1;
            $response['status'] = $api_response_code[$response['code']]['HTTP Response'];
            $loginData = new UserLogin();
            $username = stripslashes($_POST['email']);
            $password = stripslashes($_POST['password']);
            $loginData->mapIncomingLoginParams($username, $password);
            $response['loginStatus'] = $loginData->userLoginDetails();
            deliver_response($_POST['format'], $response, false);
        } else {
            if (strcasecmp($_POST['method'], 'checkemail') == 0) {
                $response['code'] = 1;
                $response['status'] = $api_response_code[$response['code']]['HTTP Response'];
                $objuserDetails = new ForgotPassword();
                $email = stripslashes($_POST['email']);
                $response['checkemailResponse'] = $objuserDetails->CheckingEmail($email);
                deliver_response($_POST['format'], $response, false);
            } else {
                if (strcasecmp($_POST['method'], 'setNewPassword') == 0) {
                    $response['code'] = 1;
                    $response['status'] = $api_response_code[$response['code']]['HTTP Response'];
                    $objuserDetails = new ForgotPassword();
                    $activationCode = stripslashes($_POST['code']);
                    $newPassword = stripslashes($_POST['password']);
                    $email = stripslashes($_POST['email']);
                    $response['setNewPasswordResponse'] = $objuserDetails->SettingNewPassword($activationCode, $newPassword, $email);
                    deliver_response($_POST['format'], $response, false);
                }
            }
        }
    }
}