示例#1
0
 /** Login Sample action to login user through SSO */
 public function action_login()
 {
     $view = View::factory('user/login');
     if ($_POST) {
         $login = SSO::login(Arr::get($_POST, 'username'), Arr::get($_POST, 'password'));
         if ($login->response_code == SSO::SUCCESS) {
             // @@TODO: $login->data is the user object... You can have a local copy of user data for this session...
             Request::current()->redirect('home');
         } else {
             switch ($login->response_code) {
                 case SSO::ERROR_INCORRECT_USERNAME:
                 case SSO::ERROR_INCORRECT_PASSWORD:
                     $view->errors = 'Invalid userid/password';
                     break;
                 default:
                     $view->errors = 'An unknown error occured';
             }
         }
     } else {
         if (SSO::is_logged_in() != '') {
             Request::current()->redirect('home');
         }
     }
     $this->response->body($view);
 }
示例#2
-1
 /**
  * Handle Request.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return \Illuminate\Http\Response response.
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return SSO::login($request->fullUrl());
         }
     }
     return $next($request);
 }