hacklee / laravel5-multi-auth by hacklee

laravel5 mutil auth
4,068
11
2
Package Data
Maintainer Username: hacklee
Maintainer Contact: 517184100@qq.com (hacklee)
Package Create Date: 2015-03-04
Package Last Update: 2015-03-04
Language: PHP
License: MIT
Last Refreshed: 2024-04-30 15:15:06
Package Statistics
Total Downloads: 4,068
Monthly Downloads: 29
Daily Downloads: 5
Total Stars: 11
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

ravel5 多个Auth实现 License ###参考 https://github.com/ollieread/multiauth 写的4.2版思路

##使用composer加载到项目

  • 修改composer.json 增加下面的require
 "require": {
    "hacklee/laravel5-multi-auth": "dev-master"
 }
  • 执行 composer update

##使用步骤

  • 替换app.config 中的'Illuminate\Auth\AuthServiceProvider' 为 'Hacklee\Multiauth\XhAuthServiceProvider'
  • 更改auth.php

配置示例:

<?php
return [ 
		'cp' => [ 
				'driver' => 'cp',
				
				'model' => 'App\CpUser',
				
				'table' => 'cp_user',
				
				'password' => [ 
						'email' => 'emails.password',
						'table' => 'password_resets',
						'expire' => 60 
				] 
		],
		'op' => [ 
				'driver' => 'op',
				
				'model' => 'App\OpUser',
				
				'table' => 'op_user',
				
				'password' => [ 
						'email' => 'emails.password',
						'table' => 'password_resets',
						'expire' => 60 
				] 
		],
		'api' => [ 
				'driver' => 'api',
				
				'model' => 'App\ApiUser',
				
				'table' => 'api_user',
				
				'password' => [ 
						'email' => 'emails.password',
						'table' => 'password_resets',
						'expire' => 60 
				] 
		] 
];

##使用示例

Auth::cp()->attempt();
Auth::api()->attempt();
Auth::op()->attempt();