コード例 #1
0
 public function action_confirm()
 {
     $success = false;
     $msg = array();
     $user = null;
     try {
         $token = Request::active()->param('token');
         $user = \Warden\Model_User::confirm_by_token($token);
         if ($user) {
             $msg[] = 'Welcome ' . $user->username . ', your account is now activated.';
             $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) {
         $claim = \Session::get('claim', null);
         if ($claim && $user && $claim['user_id'] === $user->id) {
             if ($claim['user_id'] === $user->id) {
                 $msg[] = !empty($claim['agency_id']) ? 'Please login again to complete your claim.' : 'Please login again to add your organization.';
             }
         } else {
             $msg[] = 'Please login again.';
         }
         \Session::set_flash('success', $msg);
     } else {
         $msg[] = 'Please login again to receive a new activation email.';
         \Session::set_flash('error', $msg);
     }
     Response::redirect('/user/login');
 }