This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » User management plugins » [DONE] sfGuard - retrieve password or getter for the password in cleartext
[DONE] sfGuard - retrieve password or getter for the password in cleartext [message #57112] Sun, 27 July 2008 09:56 Go to next message
flo_w
Messages: 22
Registered: June 2008
Junior Member
hola everyone!

i just can't find anything about that...

i have this in my routing.yml - according to sfGuard readme:

sf_guard_password:
  url:   /request_password
  param: { module: sfGuardAuth, action: password }


but it just gives me the login. i find no actions for pw-retrieval and doing it myself i can just get the crypted password via

$this -> getUser() -> getGuardUser() -> getPassword();


which of course does not help me much.

i have a strong feeling that i am missing something - big time... someone please push me into the right direction.

thanks and have a nice day!
_f

[Updated on: Sun, 27 July 2008 20:53]

Re: sfGuard - retrieve password or getter for the password in cleartext [message #57116 is a reply to message #57112 ] Sun, 27 July 2008 15:23 Go to previous messageGo to next message
tripats  is currently offline tripats
Messages: 7
Registered: August 2007
Junior Member
Hi,
passwords are encrypted by default and so there is no way to retrieve them decrypted.
The only way is to set a new one.
AFAIK the method is not implemented so you have to do one on your own. For example:
 public function executePasswordRequest()
  {
    if ($this->getRequest()->getMethod() != sfRequest::POST)
    {
      // display the form
      return sfView::SUCCESS;
    }

    // handle the form submission
   
    $c = new Criteria();
    $c->add(sfGuardUserProfilePeer::EMAIL, $this->getRequestParameter('email'));
    $user_profile = sfGuardUserProfilePeer::doSelectOne($c);
    $d = new Criteria();
    $d->add(sfGuardUserPeer::ID, $user_profile->getUserId());
    $user = sfGuardUserPeer::doSelectOne($d);
    // email exists?
    if ($user_profile)
    {
      // set new random password
      $password = substr(md5(rand(100000, 999999)), 0, 6);
      $user->setPassword($password);

      $this->getRequest()->setAttribute('password', $password);
      $this->getRequest()->setAttribute('nickname', $user->getUserName());

      $raw_email = $this->sendEmail('mail', 'sendPassword');
      $this->getLogger()->debug($raw_email);

      // save new password
      $user->save();

      return 'MailSent';
    }
    else
    {
      $this->getRequest()->setError('email', 'There is no user with this email address. Please try again');

      return sfView::SUCCESS;
    }
  }


As you can see, you need a sfGuardUserProfile with an email field to send the new password to a user.
This code I took from motilee forum engine http://www.motilee.com/motilee.tgz initiated by Fran├žois Zaninotto.
It might be a good approach to download the source and have a look at it ... and understand it Smile
Hope it helps, greetz, trip
Re: sfGuard - retrieve password or getter for the password in cleartext [message #57128 is a reply to message #57116 ] Sun, 27 July 2008 20:53 Go to previous messageGo to next message
flo_w
Messages: 22
Registered: June 2008
Junior Member
hola trip!

ic. no clearTextGetter()... well - i built a setter myself so that it can reset the pws....

but thanks anyways and have a nice day
_f
Re: sfGuard - retrieve password or getter for the password in cleartext [message #58583 is a reply to message #57128 ] Wed, 13 August 2008 11:49 Go to previous message
dohfr  is currently offline dohfr
Messages: 53
Registered: July 2008
Location: FRANCE
Member
there is a solution, Overriding the method for registration
without encrypting the password, but that's for sure not the greatest idea Razz

One way to do that following the previous code :
- its to generate a new encrypted password
- replace the old one by the new into the data base
- send the new one by mail to the user
- let the persone edit the password once logged

cheers
dohfr
Previous Topic:Create user with profile creation
Next Topic:sfGuard login form
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software