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

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

问题描述

我想修改Laravel 5提供的现有Authorization模块,而不是询问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 :

Illuminate \ Foundation \ Auth \ AuthenticatesUsers

Illuminate\Foundation\Auth\AuthenticatesUsers

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

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

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

不过,您可以通过添加来在AuthController中覆盖它:

However you can override it in your AuthController by adding :

protected $username = 'username';

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

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