Beispiel #1
0
 public function validateRequest(sfWebRequest $request)
 {
     $server = $this->getOAuthServer();
     $oauthRequest = $this->getOAuthRequest();
     $oauthResponse = $this->getOAuthResponse();
     if (!$server->verifyResourceRequest($oauthRequest, $oauthResponse)) {
         $server->getResponse()->send();
         throw new sfStopException();
     }
     $tokenData = $server->getAccessTokenData($oauthRequest, $oauthResponse);
     $userId = $tokenData['user_id'];
     $userService = new SystemUserService();
     $user = $userService->getSystemUser($userId);
     $authService = new AuthService();
     $authService->setLoggedInUser($user);
     $this->getAuthenticationService()->setCredentialsForUser($user, array());
 }
 public function execute($request)
 {
     $this->form = new ChangeUserPasswordForm();
     $this->userId = $this->getUser()->getAttribute('user')->getUserId();
     $systemUserService = new SystemUserService();
     $systemUser = $systemUserService->getSystemUser($this->userId);
     $this->username = $systemUser->getName();
     if ($this->getUser()->hasFlash('templateMessage')) {
         $this->templateMessage = $this->getUser()->getFlash('templateMessage');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             if (!$systemUserService->isCurrentPassword($this->userId, $this->form->getValue('currentPassword'))) {
                 $this->getUser()->setFlash('templateMessage', array('WARNING', __('Current Password Is Wrong')));
                 $this->redirect('admin/changeUserPassword');
             } else {
                 $this->form->save();
                 $this->getUser()->setFlash('templateMessage', array('SUCCESS', __('Successfully Changed')));
                 $this->redirect('admin/changeUserPassword');
             }
         }
     }
 }