当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentry::authenticateAndRemember方法代码示例

本文整理汇总了PHP中Sentry::authenticateAndRemember方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::authenticateAndRemember方法的具体用法?PHP Sentry::authenticateAndRemember怎么用?PHP Sentry::authenticateAndRemember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentry的用法示例。


在下文中一共展示了Sentry::authenticateAndRemember方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginTry

 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.');
     }
 }
开发者ID:Belar,项目名称:librific,代码行数:29,代码来源:AuthController.php

示例2: do_login

 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.']);
     }
 }
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:28,代码来源:AuthenticationController.php

示例3: postLogin

 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);
 }
开发者ID:vanherba,项目名称:linda,代码行数:25,代码来源:AuthController.php

示例4: login

 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.'));
     }
 }
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:27,代码来源:FrontendController.php

示例5: postIndex

 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('');
 }
开发者ID:richarrieta,项目名称:miequipo,代码行数:26,代码来源:LoginController.php

示例6: GET_loginUser

 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'));
     }
 }
开发者ID:kayrules,项目名称:laravel-starter,代码行数:39,代码来源:AuthController.php


注:本文中的Sentry::authenticateAndRemember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。