简体   繁体   English

laravel 5.2更改默认登录功能

[英]laravel 5.2 changing default login function

How can I change the default login page on laravel 5.2, I already changed: 我已经更改了如何在laravel 5.2上更改默认登录页面:

Added "protected $username = 'my_new_field';" to AuthController.php 
Added "protected $table = 'user';" to Users.php

What I wanted to do here is that instead of using email to login, I want to use user_id as username, but even after all those changes I still get: 我想在这里做的是,我想使用user_id作为用户名,而不是使用电子邮件登录,但是即使经过所有这些更改,我仍然会得到:

"These credentials do not match our records." “这些凭据与我们的记录不匹配。” , What could be causing this? ,这可能是什么原因造成的?

Also instead of using "users" table I am using "user" 此外,我不是在使用“用户”表,而是在使用“用户”

如果您正在考虑更改laravel默认登录名,但仅使用用户名而不是电子邮件,那么我建议您在AuthenticatesUsers.php上进行更改,在这里您可以找到public function postLogin(Request $request)并且如果有许多字段,您可以更改请求需求需要,我建议您https://laravel.com/docs/5.2/authentication#adding-custom-guards

您可以通过重写AuthControllergetCredentials()方法来AuthController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM