hacklee/laravel5-multi-auth

laravel5 mutil auth

dev-master 2015-03-04 11:26 UTC

This package is not auto-updated.

Last update: 2024-11-13 07:20:43 UTC


README

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();