定制 puz/multicolumnauth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

puz/multicolumnauth

Composer 安装命令:

composer require puz/multicolumnauth

包简介

Makes it possible to log in with both a username and / or email

README 文档

README

Ever felt like you need to allow both a username and email field? Then you're in luck!
Puz MultiColumnAuth enables you to allow your users to use whatever userfield they want to when they log in!

Installation

composer require puz/multicolumnauth

You will need to update your config/app.php by adding the service provider to your application.
Add this under the provider section: Puz\MultiColumnAuth\ServiceProvider::class

To configure your fields and columns you'll need to add my configuration files. Simply do this by running the artisan command php artisan vendor:publish

The last thing you have to do now, is to replace the current Authorization trait. In the default AuthController class, you will see that laravel have included use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;. If you're still using both the authentication and registration of users, simply change this to: use Puz\MultiColumnAuth\AuthenticatesAndRegistersUsers;. If you don't need registration, simply change it to use Puz\MultiColumnAuth\AuthenticatesUsers;, or do the same if you have a custom registration trait maybe and need to include this AuthenticatesUsers in your custom class. In short, there are two available trais:
Puz\MultiColumnAuth\AuthenticatesAndRegistersUsers
Puz\MultiColumnAuth\AuthenticatesUsers

How to

Select which columns I can use for login
In your newly created config file from php artisan vendor:publish located in config/puz/multicolumnauth.php, there exists a array with a key named columns. This key takes an array as a value with the columns you want the users to log in with. Ex: ['username', 'email'] will check for the username column and then email.

Select name of login field
In the same config file, you have a key loginfield. This is set to login as default. This means that the input field where you usually inputs a username or email, you use the name login, or to something you freely choose yourself.

How does it work?

If you have specified columns to log in with, if will loop through each one and try to log in. If it succeeds by one of then (first one to succeed), then it will log in with that.

There is a catch tho.. If you for an example have set the columns to allow username, phone and email, in that specific order, then you have to be alert what the username might be. Someone can have created a username as someone else email. If they by any chance have the same password, someone will have access to another account.

As a fallback if you want to use laravel's default, you can simply change the columns in the config to a null value, like this

[
    'columns' => null,
]

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-01-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固