使用Laravel 5.4进行自定义登录密码检查 [英] Custom login password check with Laravel 5.4

查看:46
本文介绍了使用Laravel 5.4进行自定义登录密码检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户尝试登录我的Laravel应用程序,并且密码与数据库中的"password"列不匹配,我也想针对另一个密码列("old_system_password")进行检查.

If a user tries to log into my Laravel application and the password won't match with the "password" column in the database, I want to check it against another password column ("old_system_password") too.

我使用的是默认的Laravel身份验证系统,据我了解,我应该能够创建一个新的"AuthController"并覆盖内置的身份验证方法.但是我在vendor文件夹中找不到用于处理密码匹配的任何方法,也不知道如何告诉Laravel使用我的方法而不是默认方法.

I'm using the default Laravel authentication system, and as far as I understand I should be able to create a new "AuthController" and override the built in authentication methods. But I don't find any methods dealing with password matching in the vendor folder, and neither do I know how to tell Laravel to use my method instead of the default.

我已经在网上搜索了此信息,但是我发现的任何解决方案似乎仅适用于Laravel的较早版本.

I've searched the web for this, but any solutions I find seems to be only for older versions of Laravel.

有什么想法吗?

推荐答案

默认情况下,可能尝试使用如下所示的身份验证中间件:

Probably try using the Middleware of the authentication looking like this by default:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect('/home');
        }

        return $next($request);
    }
}

尝试检查用户是否已通过身份验证,然后如果未调用该函数,则该函数将使用您的密码并签入您的数据库.

Try to check if the user has been authenticated then if not call a function that will take your password and check in your database.

这篇关于使用Laravel 5.4进行自定义登录密码检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆