Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function rules()
- {
- return array(
- // username and password are required on login
- array('username, password', 'required', "on" => 'login'),
- array('username', 'email', "on" => 'login'),
- // forgotPasswordEmail is required on forgotPassword
- array('forgotPasswordEmail', 'required', "on" => 'forgotPassword'),
- array('forgotPasswordEmail', 'email', "on" => 'forgotPassword'),
- // rememberMe needs to be a boolean
- array('rememberMe', 'boolean'),
- // password needs to be authenticated
- array('password', 'authenticate'),
- );
- }
- ------------------------------------------------------
- public function actionLogin()
- {
- $loginFormModel=new LoginForm;
- $invitationRegistrationModel=new InvitationRegistration;
- // if it is ajax validation request
- /*if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
- {
- echo CActiveForm::validate($model);
- Yii::app()->end();
- }*/
- // collect user input data
- if(isset($_POST['LoginForm']))
- {
- //See if the "Forgot Email" checkbox was checked
- if( isset($_POST['LoginForm']['forgotPassword']) ) {
- $loginFormModel->setScenario('forgotPassword');
- $loginFormModel->attributes=$_POST['LoginForm'];
- print_r($loginFormModel->scenario);
- if( $loginFormModel->validate() )
- {
- //If the email is validated, see if it is in the database.
- $user = Users::model()->findByAttributes('email','WHERE email = '.$loginFormModel->forgotPasswordEmail);
- print_r($user);
- die();
- //If it is in the database, change the password for the user to some random string of letters.
- //Send the new password in an email to the user.
- }
- ......
Add Comment
Please, Sign In to add comment