Example #1
0
 /**
  * @PublicPage
  */
 public function setPassword($token, $userId, $password)
 {
     try {
         $user = $this->userManager->get($userId);
         if (!$this->checkToken($userId, $token)) {
             throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
         }
         if (!$user->setPassword($password)) {
             throw new \Exception();
         }
         // FIXME: should be added to the all config at some point
         \OC_Preferences::deleteKey($userId, 'owncloud', 'lostpassword');
         $this->userSession->unsetMagicInCookie();
     } catch (\Exception $e) {
         return $this->error($e->getMessage());
     }
     return $this->success();
 }