承接 kbwebs/multiauth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kbwebs/multiauth

最新稳定版本:v1.0

Composer 安装命令:

composer require kbwebs/multiauth

包简介

MultiAuth for Laravel 5.1

README 文档

README

Installation

First, pull in the package through Composer.

"require": {
    "kbwebs/multiauth": "~1.0"
}

Now you'll want to update or install via composer.

composer update

Authentication

Open up the config/app.php file and replace the AuthServiceProvider with:

Illuminate\Auth\AuthServiceProvider::class -> Kbwebs\MultiAuth\AuthServiceProvider::class

And open config/auth.php file and remove:

'driver'  => 'eloquent'
'model'   => App\User::class,
'table'   => 'users'

and replace it with this array:

'multi-auth' => [
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class
    ],
    'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class
    ]
]

If you want to use Database instead of Eloquent you can use it as:

'user' => [
    'driver' => 'database',
    'table'  => 'users'
]

Password Resets

Open up config/app.php file and replace the PasswordResetServiceProvider with:

Illuminate\Auth\Passwords\PasswordResetServiceProvider::class -> Kbwebs\MultiAuth\PasswordResets\PasswordResetServiceProvider::class

If you want to use the password resets from this Package you will need to change this in each Model there use password resets:

use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

to

use Kbwebs\MultiAuth\PasswordResets\CanResetPassword;
use Kbwebs\MultiAuth\PasswordResets\Contracts\CanResetPassword as CanResetPasswordContract;

If you want to change the view for password reset for each auth type you can add this to the multi-auth array in config/auth.php:

'email' => 'emails.users.password'

If you dont add this line, Laravel will automatically use the default path for emails.password like its defined in the password array.

To generate the password resets table you will need to run the following command:

php artisan kbwebs:multi-auth:create-resets-table

Likewise, if you want to clear all password resets, you have to run the following command:

php artisan kbwebs:multi-auth:clear-resets

NOTE It is very important that you replace the default service providers. If you do not wish to use Password resets, then remove the original Password resets server provider as it will cause errors.

Usage

Authentication:

It works just like the original laravel authentication library, the only change is the user() or admin() it will match the auth type, as your defining in the multi-auth array:

Auth::attempt(['email' => $email, 'password' => $password], $remember)

But now it has to be like, with the user() or admin():

Auth::user()->attempt(['email' => $email, 'password' => $password], $remember)

If you want to access the information for the authenticated user, you can do this:

Auth::user()->get();

OR

Auth::user()->get()->email

Password resets:

It works just like the original laravel authentication library, the only change is the user() or admin() it will match the auth type, as your defining in the multi-auth array:

Password::sendResetLink($request->only('email'), function (Message $message) {
    $message->subject($this->getEmailSubject());
});

But now it has to be like, with the user() or admin():

Password::user()->sendResetLink($request->only('email'), function (Message $message) {
    $message->subject($this->getEmailSubject());
});

Example for a password reset email:

Click here to reset your password: {{ URL::to('password/reset', array($type, $token)) }}.

This generates a URL like the following:

http://example.com/password/reset/user/21eb8ee5fe666r3b8d0521156bbf53266bnca572

Which will match the following route:

Route::get('password/reset/{type}/{token}', 'Controller@method');

Tip:

Remember to update all places where ex: Auth:: is been using, to ex: Auth::user() or what you have defined in config/auth.php

kbwebs/multiauth 适用场景与选型建议

kbwebs/multiauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89.42k 次下载、GitHub Stars 达 139, 最近一次更新时间为 2015 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「user」 「login」 「auth」 「laravel」 「multi」 「signin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kbwebs/multiauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kbwebs/multiauth 我们能提供哪些服务?
定制开发 / 二次开发

基于 kbwebs/multiauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 89.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 143
  • 点击次数: 21
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 139
  • Watchers: 12
  • Forks: 37
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-14