Пример #1
0
 public function check(Application $app, $validateKey = '')
 {
     $userActivated = false;
     $userModel = new UserModelBase();
     if ($userModel->readByProperty('validationKey', $validateKey)) {
         if ($userModel->validate()) {
             $userModel->active = true;
             $userModel->write();
             $userActivated = true;
         }
     }
     if ($userActivated) {
         return $this->renderPage($app, 'validate');
     } else {
         // if the validation has expired, chances are they have already validated.  Redirect to login
         return $app->redirect('/auth/login');
     }
 }
Пример #2
0
 /**
  *    Removes a user from the collection
  *  Project references to this user are also removed
  */
 public function remove()
 {
     foreach ($this->projects->refs as $id) {
         $project = new ProjectModel($id->asString());
         $project->removeUser($this->id->asString());
         $project->write();
     }
     parent::remove();
 }
Пример #3
0
 /**
  * @param Application $app
  * @param string $resetPasswordKey
  * @param string $newPassword
  * @throws \Api\Library\Shared\Palaso\Exception\UserUnauthorizedException
  */
 public static function resetPassword(Application $app, $resetPasswordKey = '', $newPassword = '')
 {
     $user = new UserModelBase();
     if ($user->readByProperty('resetPasswordKey', $resetPasswordKey)) {
         $userId = $user->id->asString();
         if ($user->hasForgottenPassword()) {
             UserCommands::changePassword($userId, $newPassword, $userId);
             $user->write();
             $app['session']->getFlashBag()->add('infoMessage', 'Your password has been reset. Please login.');
         } else {
             $app['session']->getFlashBag()->add('errorMessage', 'Your password reset cannot be completed. It may have expired. Please try again.');
         }
     } else {
         $app['session']->getFlashBag()->add('errorMessage', 'Your password reset cannot be completed. Please try again.');
     }
 }