修改现有的授权模块(电子邮件到用户名) [英] Modify existing Authorization module (email to username)

查看:23
本文介绍了修改现有的授权模块(电子邮件到用户名)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改 Laravel 5 提供的现有授权模块,而不是要求 email 它会要求数据库中的 username 字段.>

I would like to modify the existing Authorization module provided by Laravel 5, instead of asking for the email it will ask for the username field in the database.

推荐答案

Laravel 在文件中搜索 $username 变量:

Laravel search the variable $username in the file :

IlluminateFoundationAuthAuthenticatesUsers

IlluminateFoundationAuthAuthenticatesUsers

public function loginUsername() {
    return property_exists($this, 'username') ? $this->username : 'email';
}

如您所见,默认情况下它将被命名为电子邮件".

As you can see, by default it will be named as 'email'.

但是,您可以通过添加:

However you can override it in your AuthController by adding :

protected $username = 'username';

这篇关于修改现有的授权模块(电子邮件到用户名)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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