如何在LARAVEL 5上更改身份验证的默认用户名/电子邮件/密码?

时间:2022-10-16 14:44:00

I already search for this thing but I'm really new at this and I can't figure it out how to make it work. I'm using a project without many changes so I have my User.php as it comes but I add this:

我已经搜索过这个东西了但是我真的很新,我无法弄清楚如何使它工作。我正在使用一个没有很多更改的项目,所以我有User.php,但是我添加了这个:

protected $fillable = ['username', 'email', 'password'];//GEN_ID_Usuario

/**
 * The attributes excluded from the model's JSON form.
 *
 * @var array
 */
protected $hidden = ['password', 'remember_token'];

/**
* The eloquent relation to assigment a "formulario" model.
*
*/

public function getAuthPassword()
{
    return $this->Usu_Contrasenia;
}

And I have my AuthController as default but I added this:

我将我的AuthController作为默认设置,但我添加了这个:

public function authenticate()
{
    $email = $input['email'];
    $password = $input['password']; 
    if (Auth::attempt(array('Usu_Email' => $email, 'Usu_Contrasenia' => 
    $password)))        
    {
        return redirect()->intended('dashboard');
    }
}

Everything else in the project it's by default, just trying to use username, email and password as: Usu_Nombre, Usu_Email and Usu_Contrasenia.

默认情况下,项目中的其他所有内容,只是尝试使用用户名,电子邮件和密码:Usu_Nombre,Usu_Email和Usu_Contrasenia。

1 个解决方案

#1


Based on the comments exchange, try the following:

根据评论交换,尝试以下内容:

public function authenticate()
{
    $email = $input['email'];
    $password = $input['password']; 
    if (Auth::attempt(array('Usu_Email' => $email, 'password' => 
    $password)))        
    {
        return redirect()->intended('dashboard');
    }
}

Keep in mind the stored password must be properly hashed for Auth:attemp() to work as intended.

请记住,存储的密码必须正确散列,以便Auth:尝试()按预期工作。

#1


Based on the comments exchange, try the following:

根据评论交换,尝试以下内容:

public function authenticate()
{
    $email = $input['email'];
    $password = $input['password']; 
    if (Auth::attempt(array('Usu_Email' => $email, 'password' => 
    $password)))        
    {
        return redirect()->intended('dashboard');
    }
}

Keep in mind the stored password must be properly hashed for Auth:attemp() to work as intended.

请记住,存储的密码必须正确散列,以便Auth:尝试()按预期工作。