Example #1
0
 public function action_unlock()
 {
     $success = false;
     $msg = array();
     try {
         $token = Request::active()->param('token');
         $user = \Warden\Model_User::unlock_access_by_token($token);
         if ($user) {
             $msg[] = 'Welcome ' . $user->username . ', your account is now unlocked.';
             $msg[] = 'You can now login.';
             $success = true;
         } else {
             $msg[] = 'Invalid token.';
         }
     } catch (\Warden\Failure $ex) {
         // token has expired (if enabled)
         $msg[] = $ex->getMessage();
     } catch (Exception $ex) {
         // Server/DB error
         $msg[] = 'Oops, something went wrong.';
     }
     if ($success) {
         \Session::set_flash('success', $msg);
     } else {
         \Session::set_flash('error', $msg);
     }
     Response::redirect('/user/login');
 }