本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::getLastAttempted方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::getLastAttempted方法的具体用法?PHP Guard::getLastAttempted怎么用?PHP Guard::getLastAttempted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Guard
的用法示例。
在下文中一共展示了Guard::getLastAttempted方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postLogin
/**
* Handle request login
* @param LoginRequest $request
* @param Guard $auth
* @return Response
*/
public function postLogin(LoginRequest $request, Guard $auth)
{
$logValue = $request->input('log');
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
$message = "内容を入力してください。";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
$message = "内容を入力してください。";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
$user = $auth->getLastAttempted();
if ($user) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, false);
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect(route('top'));
}
$request->session()->put('user_id', $user->id);
$message = "内容を入力してください。";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
示例2: postLogin
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param App\Services\MaxValueDelay $maxValueDelay
* @param Guard $auth
* @return Response
*/
public function postLogin(LoginRequest $request, Guard $auth)
{
$logValue = $request->input('log');
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
}
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
}
$user = $auth->getLastAttempted();
if ($user->confirmed) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect('/');
}
$request->session()->put('user_id', $user->id);
return redirect('/auth/login')->with('error', trans('front/verify.again'));
}
示例3: postLogin
public function postLogin(LoginRequest $request, Guard $auth)
{
$email = $request->input('email');
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return redirect('/admin/login')->with('error', '세션이 만료되었습니다')->withInput($request->only('email'));
}
$credentials = ['email' => $email, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect('/admin/login')->with('error', '사용자를 찾을 수 없습니다')->withInput($request->only('email'));
}
$user = $auth->getLastAttempted();
if ($user->confirmed) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect('/admin/dashboard');
}
$request->session()->put('user_id', $user->id);
return redirect('/admin/login')->with('error', '사용자를 다시 인증하세요');
}
示例4: postLogin
/**
* Login action.
*
* @param LoginRequest $request
* @param Guard $auth
* @return \Illuminate\Http\JsonResponse
*/
public function postLogin(LoginRequest $request, Guard $auth)
{
$input = $request->all();
// Filter login with email or name.
$logAccess = filter_var($input['log'], FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
// Throttle
$throttle = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttle && $this->hasTooManyLoginAttempts($request)) {
return response()->json(['return' => false, 'value' => 'Too many attempts.']);
}
$credentials = [$logAccess => $input['log'], 'password' => $input['password']];
if (!$auth->validate($credentials)) {
if ($throttle) {
$this->incrementLoginAttempts($request);
}
return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
}
$user = $auth->getLastAttempted();
if ($user) {
if ($throttle) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $input['remember']);
session()->put('user_name', $user->name);
session()->put('user_email', $user->email);
return response()->json(['return' => true, 'value' => url('/dashboard')]);
}
return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
}
示例5: postLogin
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param App\Services\MaxValueDelay $maxValueDelay
* @param Guard $auth
* @return Response
*/
public function postLogin(MaxValueDelay $maxValueDelay, Guard $auth)
{
//Se obtiene los datos que llegan del formulario
$request = Request::all();
//Se almacena en una variable el campo de email-username
$logValue = $request['log'];
//Se verifica que no se encuentre en cache - maxValueDelay se encuentra en servicios
if ($maxValueDelay->check($logValue)) {
return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
}
//Valida que valor ingresaron, email - username
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
//Se almacenan en un objeto
$credentials = [$logAccess => $logValue, 'password' => $request['password']];
if (!$auth->validate($credentials)) {
//Guarda en cache el intento erroneo
$maxValueDelay->increment($logValue);
return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request);
}
//Obtiene el ultimo intento realizado
$user = $auth->getLastAttempted();
//Si el ultimo intento que realizo es 1 ingresa
//Valida que si ya esta logueado no ingrese al loguin
if ($user->confirmed) {
$c = isset($request['memory']) ? true : false;
$auth->login($user, $c);
if (Request::session()->has('user_id')) {
Request::session()->forget('user_id');
}
return redirect('/home');
}
Request::session()->put('user_id', $user->id);
return redirect('/auth/login')->with('error', trans('front/verify.again'));
}
示例6: postLogin
public function postLogin(LoginRequest $request, Guard $auth)
{
$logValue = $request->input('log');
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
$message = "Đăng nhập vượt quá số lần quy định.";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
$message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
$user = $auth->getLastAttempted();
if ($user->confirmed) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect(route('website.index'));
}
$request->session()->put('user_id', $user->id);
$message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
$alertClass = "alert-danger";
return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
}
示例7: postLogin
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param App\Services\MaxValueDelay $maxValueDelay
* @param Guard $auth
* @return Response
*/
public function postLogin(LoginRequest $request, Guard $auth, ServiciosOperadorRepository $gestion)
{
$logValue = $request->input('log');
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return redirect('/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
}
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect('/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
}
$user = $auth->getLastAttempted();
if ($user->confirmed || $user->valid) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
$request->session()->put('user_name', $user->username);
$email = $auth->user()->email;
$nombre = $auth->user()->user_name;
/* Busca si ya tiene servicios activos o no */
//logica que comprueba si el usuario tiene servicios para ser modificados
//caso contrario ingresa nuevos serviciosS
$listServicios = $gestion->getServiciosidUsuario($user->id);
if ($listServicios) {
$data['id_usuario_op'] = $listServicios[0]->id_usuario_op;
$request->session()->put('operador_id', $data['id_usuario_op']);
// $view = view('Registro.catalogoServicio', compact('data', 'listServicios'));
$request->session()->put('tip_oper', $listServicios[0]->id_tipo_operador);
return redirect('/detalleServicios')->with('user', $user->id);
// return ($view);
} else {
return redirect('/myProfileOp')->with('user', $user->id);
}
} else {
/* --------------------------------- */
return redirect('/login')->with('error', trans('front/verify.again'))->withInput($request->only('log'));
}
}
示例8: postLogin
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param App\Services\MaxValueDelay $maxValueDelay
* @param Guard $auth
* @return Response
*/
public function postLogin(LoginRequest $request, MaxValueDelay $maxValueDelay, Guard $auth)
{
$logValue = $request->input('log');
if ($maxValueDelay->check($logValue)) {
return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
}
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
$maxValueDelay->increment($logValue);
return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
}
$user = $auth->getLastAttempted();
if ($user->confirmed) {
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect('/');
}
$request->session()->put('user_id', $user->id);
return redirect('/auth/login')->with('error', trans('front/verify.again'));
}
示例9: postEBLogin
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param Guard $auth
* @return Response
*/
public function postEBLogin(LoginRequest $request, Guard $auth)
{
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
if ($request->ajax()) {
return response(trans('front/login.maxattempt'), 422)->header('Content-Type', 'application/json');
} else {
return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('username'));
}
}
$credentials = $request->only('username', 'password');
if (!$auth->validate($credentials)) {
if ($throttles) {
// $request->merge(['remember'=>true]);
$this->incrementLoginAttempts($request);
}
$user = User::where('username', '=', $request->input('username'))->first();
if ($user === null) {
// user doesn't exist
if ($request->ajax()) {
return response('Wrong username', 422)->header('Content-Type', 'application/json');
} else {
return redirect('/auth/login')->with('error', 'Wrong username')->withInput();
}
} else {
// Wrong username
if ($request->ajax()) {
return response('Wrong password', 422)->header('Content-Type', 'application/json');
} else {
return redirect('/auth/login')->with('error', 'Wrong password')->withInput();
}
}
}
$user = $auth->getLastAttempted();
// if($user->confirmed) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return response(['msg' => 'ok'], 200)->header('Content-Type', 'application/json');
// }
}