Yii Framework Forum: Forgot Password Functionality - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Forgot Password Functionality How will I implement the for got password? Rate Topic: ****- 1 Votes

#1 User is offline   ni3nitin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-July 13

Posted 20 July 2013 - 01:27 AM

I want to perform forgot password functionality in my existing website. could please guys guide me how will I perform it.As I am new in YII.


THanks,
0

#2 User is offline   Abhishek Shah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 20-July 12
  • Location:New Jersey,USA

Posted 20 July 2013 - 01:40 AM

Have you save email address or mobile no of user?
Than,user will enter his login account,you have to fetch mobile no/email of it.
Just make a random number string,reset his password with that number,send message on mobile through curl,or send it by mail.
Feel free to ask for help,
Abhishek.
Freelancer.
Yii Basic Gii With Export Pdf Excel
0

#3 User is offline   ni3nitin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-July 13

Posted 20 July 2013 - 01:55 AM

View PostAbhishek Shah, on 20 July 2013 - 01:40 AM, said:

Have you save email address or mobile no of user?
Than,user will enter his login account,you have to fetch mobile no/email of it.
Just make a random number string,reset his password with that number,send message on mobile through curl,or send it by mail.




Thanks for you replay.

yes I have stored emailID in database.Please attach here all the script including model,view & controller.with validation and all thing.
0

#4 User is offline   Abhishek Shah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 20-July 12
  • Location:New Jersey,USA

Posted 20 July 2013 - 01:59 AM

Please try to do yourself.If any error occure , share here,will help you.
Feel free to ask for help,
Abhishek.
Freelancer.
Yii Basic Gii With Export Pdf Excel
0

#5 User is offline   Devendra411 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 09-April 13
  • Location:Bangalore

Posted 20 July 2013 - 10:43 AM

Hi Nitin try this way may be this will help to you
public function actionForgotPassword() {
    	$model = new User('passwordReset');
    	$model->setScenario('forgotPassword');
    	$hash = '';
    	if (isset($_POST['User'])) {
        	$model->attributes = $_POST['User'];
        	if ($model->validate()) {
            	$model = User::model()->findByEmail($_POST['User']['email']);
            	$timestamp = time();
            	$hash = crypt($model->email . $model->password . $timestamp);
            	Shared::debug($hash);
            	$model->password_reset = $timestamp;
            	// save the timestamp (password reset is good for 24 hours only)
            	$model->save();

            	$mail = new Mailer('forgotPass', array('hash' => $hash));
            	/**
             	* Be sure to configure properly! Check https://github.com/Synchro/PHPMailer for documentation.
             	*/
            	$mail->render();
            	$mail->From = app()->params['adminEmail'];
            	$mail->FromName = app()->params['adminEmailName'];
            	$mail->Subject = app()->name . ' Password Reset';
            	$mail->AddAddress($model->email);
            	if ($mail->Send()) {
                	$mail->ClearAddresses();
                	app()->user->setFlash('success', 'Please check your email for further instructions.');
                	$this->redirect(array('/site/index'));
            	} else {
                	app()->user->setFlash('error', 'Error while sending email: ' . $mail->ErrorInfo);
            	}
        	}
    	}
    	$this->render('forgot_password', array('model' => $model));
	}


All the best......
0

#6 User is offline   ni3nitin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-July 13

Posted 20 July 2013 - 11:20 AM

View PostAbhishek Shah, on 20 July 2013 - 01:59 AM, said:

Please try to do yourself.If any error occure , share here,will help you.




I was done with all the forgot password functionality.
Thanks for your support here.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users