Guest User

Untitled

a guest
May 24th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1.     public function rules()
  2.     {
  3.         return array(
  4.             // username and password are required on login
  5.             array('username, password', 'required', "on" => 'login'),
  6.             array('username', 'email', "on" => 'login'),
  7.             // forgotPasswordEmail is required on forgotPassword
  8.             array('forgotPasswordEmail', 'required', "on" => 'forgotPassword'),
  9.             array('forgotPasswordEmail', 'email', "on" => 'forgotPassword'),
  10.             // rememberMe needs to be a boolean
  11.             array('rememberMe', 'boolean'),
  12.             // password needs to be authenticated
  13.             array('password', 'authenticate'),
  14.         );
  15.     }
  16.  
  17.  
  18. ------------------------------------------------------
  19.  
  20. public function actionLogin()
  21. {
  22.     $loginFormModel=new LoginForm;
  23.         $invitationRegistrationModel=new InvitationRegistration;
  24.  
  25.     // if it is ajax validation request
  26.     /*if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
  27.     {
  28.         echo CActiveForm::validate($model);
  29.         Yii::app()->end();
  30.     }*/
  31.  
  32.     // collect user input data
  33.     if(isset($_POST['LoginForm']))
  34.     {
  35.             //See if the "Forgot Email" checkbox was checked
  36.         if( isset($_POST['LoginForm']['forgotPassword']) ) {
  37.                 $loginFormModel->setScenario('forgotPassword');
  38.                     $loginFormModel->attributes=$_POST['LoginForm'];
  39.                     print_r($loginFormModel->scenario);
  40.                     if( $loginFormModel->validate() )
  41.             {
  42.                         //If the email is validated, see if it is in the database.
  43.                         $user = Users::model()->findByAttributes('email','WHERE email = '.$loginFormModel->forgotPasswordEmail);
  44.                         print_r($user);
  45.                         die();
  46.                         //If it is in the database, change the password for the user to some random string of letters.
  47.                         //Send the new password in an email to the user.
  48.             }
  49.  
  50. ......
Add Comment
Please, Sign In to add comment