コード例 #1
0
ファイル: AuthController.php プロジェクト: Belar/librific
 public function loginTry()
 {
     try {
         Input::only('email', 'password', 'remember_me');
         // Set login credentials
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // Try to authenticate the user
         if (Input::get('remember_me') == true) {
             $user = Sentry::authenticateAndRemember($credentials);
         } else {
             $user = Sentry::authenticate($credentials);
         }
         return Redirect::intended('/')->with('global_success', 'You are now logged in.');
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Redirect::to('/login')->with('login_error', 'Login field is required.');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Redirect::to('/login')->with('login_error', 'Password field is required.');
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Redirect::to('/login')->with('login_error', 'Your username/password combination was incorrect.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::to('/login')->with('login_error', 'Your username/password combination was incorrect.');
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Redirect::to('/login')->with('login_error', 'You need to activate your account before log in.');
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return Redirect::to('/')->with('global_error', 'Depends on violation, your account has been suspended or banned.');
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Redirect::to('/')->with('global_error', 'Depends on violation, your account has been suspended or banned.');
     }
 }
コード例 #2
0
 public function do_login()
 {
     try {
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         if (Input::get('remember') == 1) {
             $user = Sentry::authenticateAndRemember($credentials);
         } else {
             $user = Sentry::authenticate($credentials);
         }
         $url = Session::get('originalRequest') ? Session::get('originalRequest') : URL::to('dashboard');
         Session::forget('originalRequest');
         return Response::json(['success' => 'Login successful. You will now be redirected to the admin dashboard', 'url' => $url]);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(['email' => 'Email is required']);
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(['password' => 'Password is required.']);
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Response::json(['password' => 'Wrong password, please try again.']);
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(['email' => 'User not found.']);
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Response::json(['email' => 'User is not activated.']);
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return Response::json(['email' => 'User is suspended.']);
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Response::json(['email' => 'User is banned.']);
     }
 }
コード例 #3
0
ファイル: AuthController.php プロジェクト: vanherba/linda
 public function postLogin()
 {
     try {
         $credentials = array('email' => \Input::get('username'), 'password' => \Input::get('password'));
         $return = \Input::get('return', 'datasets');
         $user = \Sentry::authenticateAndRemember($credentials);
         // Success! Redirect back
         return \Redirect::to($return);
     } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $message = 'Username is required.';
     } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $message = 'Password is required.';
     } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) {
         $message = 'Username and/or password incorrect.';
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $message = 'Username and/or password incorrect.';
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $message = 'User is not activated.';
     } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $message = 'User is suspended.';
     } catch (\Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $message = 'User is banned.';
     }
     return \Redirect::to('login?return=' . $return . '&message=' . $message);
 }
 public function login()
 {
     try {
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         if (Input::get('remember') == 1) {
             $user = Sentry::authenticateAndRemember($credentials);
         } else {
             $user = Sentry::authenticate($credentials);
         }
         $url = URL::to('dashboard');
         return Response::json(array('success' => 'You have arrived! Hang on and we\'ll redirect you shortly', 'url' => $url));
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(array('message' => 'Login field is required'));
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(array('message' => 'Password field is required.'));
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Response::json(array('message' => 'Wrong password, please try again.'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(array('message' => 'User was not found.'));
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Response::json(array('message' => 'User is not activated.'));
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return Response::json(array('message' => 'User is suspended.'));
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Response::json(array('message' => 'User is banned.'));
     }
 }
コード例 #5
0
 public function postIndex()
 {
     try {
         $credentials = array('email' => strtolower(Input::get('email')), 'password' => Input::get('password'));
         if (Input::has('mantener')) {
             Sentry::authenticateAndRemember($credentials);
         } else {
             Sentry::authenticate($credentials, false);
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Redirect::back()->withInput()->withErrors('El usuario es requerido.');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Redirect::back()->withInput()->withErrors('La contraseña es obligatoria.');
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Redirect::back()->withInput()->withErrors('Contraseña incorrecta, intente nuevamente.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->withErrors('Este usuario no existe.');
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Redirect::back()->withInput()->withErrors('Este usuario no esta activado.');
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return Redirect::back()->withInput()->withErrors('Este usuario se encuentra suspendido.');
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Redirect::back()->withInput()->withErrors('Este usuario esta bloqueado.');
     }
     return Redirect::intended('');
 }
コード例 #6
0
 public function GET_loginUser()
 {
     try {
         // Login credentials
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         $find_user = Sentry::findUserByLogin($credentials['email']);
         if ($find_user) {
             // Authenticate the user
             $user = Sentry::authenticateAndRemember($credentials, false);
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $msg = 'Login field is required.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $msg = 'Password field is required.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         $msg = 'Wrong password, try again.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $msg = 'User was not found.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $msg = 'User is not activated.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $msg = 'User is suspended.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $msg = 'User is banned.';
         return Redirect::back()->with('STATUS_FAIL', $msg)->withInput();
     }
     $group_admin = Sentry::findGroupByName('Administrator');
     if ($user->inGroup($group_admin)) {
         return Redirect::to(route('admin'));
     } else {
         return Redirect::to(route('home'));
     }
 }