Laravel 5.0 How to implement the Login password field is not customized for password or add-on.

Source: Internet
Author: User
It took a long time to finally fully understand how laravel5.0 was signed in, and it felt very complicated.

For example, when the password field in the database is PWD instead of the system default password, the modified files are:

// \vendor\laravel\framework\src\Illuminate\Auth\Authenticatable.phppublic function getAuthPassword(){//    return $this->password; 修改为    return $this->pwd;}

If the add-on method is different, the modified files are:

// \vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.phppublic function validateCredentials(UserContract $user, array $credentials){    $plain = $credentials['password'];    // 下面的$this->hasher->check修改为自定义加签后的字符串相等判断    return $this->hasher->check($plain, $user->getAuthPassword());}

Such modification is equivalent to modifying the source code of the Laravel, is not elegant, do not know there is no better way?

Reply content:

It took a long time to finally fully understand how laravel5.0 was signed in, and it felt very complicated.

For example, when the password field in the database is PWD instead of the system default password, the modified files are:

// \vendor\laravel\framework\src\Illuminate\Auth\Authenticatable.phppublic function getAuthPassword(){//    return $this->password; 修改为    return $this->pwd;}

If the add-on method is different, the modified files are:

// \vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.phppublic function validateCredentials(UserContract $user, array $credentials){    $plain = $credentials['password'];    // 下面的$this->hasher->check修改为自定义加签后的字符串相等判断    return $this->hasher->check($plain, $user->getAuthPassword());}

Such modification is equivalent to modifying the source code of the Laravel, is not elegant, do not know there is no better way?

You can also make your own login registration AH. But I think the bring-on has been very useful.
If you add a field to the user table to get the value of the field, you canauth()->user()->你的字段名

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.