Beispiel #1
0
 public function restoreAction()
 {
     $request = $this->getRequest();
     $token = $request->getParam('token');
     $options = $this->getInvokeArg('bootstrap')->getOption('secure');
     if (!$token) {
         $this->_redirect('/');
     }
     $userProfileTable = new Rabotal_Model_UsersProfile();
     $profile = $userProfileTable->fetchRow(array('forgot_key = ?' => $token));
     if (!$profile) {
         $this->view->invalidToken = true;
     } else {
         $this->view->invalidToken = false;
         $makeNewPasswordForm = new Rabotal_Form_MakeNewPassword(array('action' => "/auth/restore/token/{$token}"));
         if ($request->isPost() && $makeNewPasswordForm->isValid($request->getPost())) {
             $user = $profile->findParentRow('Rabotal_Model_Users', 'User');
             $user->password = sha1($options['salt'] . $makeNewPasswordForm->getValue('password'));
             $user->save();
             $profile->forgot_password = NULL;
             $profile->save();
             $this->_helper->FlashMessenger->addMessage('pass-saved');
             $this->_redirect('/auth/password-saved');
         }
         $this->view->makeNewPasswordForm = $makeNewPasswordForm;
     }
 }
Beispiel #2
0
 private function _signUp($formData)
 {
     $security = $this->getInvokeArg('bootstrap')->getOption('secure');
     $usersTable = new Rabotal_Model_Users();
     $usersProfileTable = new Rabotal_Model_UsersProfile();
     $values = array('email' => $formData['email'], 'username' => $usersTable->mklogin(substr($formData['email'], 0, strpos($formData['email'], '@'))), 'password' => sha1($security['salt'] . $formData['password']), 'avatar' => '', 'role' => Rabotal_User_Enum_Roles::ROLE_DEFAULT, 'date' => time(), 'auto_signin_key' => '', 'status' => Rabotal_User_Enum_Status::STATUS_DEFAULT);
     $userId = $usersTable->insert($values);
     $usersProfileTable->insert(array('user_id' => $userId));
     Rabotal_Auth::identityWrite(array('id' => $userId, 'username' => $values['username'], 'email' => $values['email']));
     return true;
 }