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');
     }
 }
 /**
  * @param string $validationKey
  * @return array
  * @throws \Exception
  */
 public static function readForRegistration($validationKey)
 {
     $user = new UserModelBase();
     if (!$user->readByProperty('validationKey', $validationKey)) {
         return array();
     }
     if (!$user->validate(false)) {
         throw new \Exception("Sorry, your registration link has expired.");
     }
     return JsonEncoder::encode($user);
 }