當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。