本文整理汇总了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.');
}
}
示例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.']);
}
}
示例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);
}
示例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.'));
}
}
示例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('');
}
示例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'));
}
}