[李景山php]每天laravel[036]-laravel 系统服务 --- 认证-1

来源:互联网 发布:白手套 知乎 编辑:程序博客网 时间:2024/05/22 02:04

Authentication:认证:就是对用户是否登录的认证,简单的版本,而不是对权限的认证。

配置位置:config/auth.php里面。

数据库配置:

1 密码 字段长度大于60 char2 remember_token 字段最小 100 char 字段

配合的控制器:

AuthController PasswordController 

两个控制器

路由控制:

// Authentication routes...Route::get('auth/login', 'Auth\AuthController@getLogin');Route::post('auth/login', 'Auth\AuthController@postLogin');Route::get('auth/logout', 'Auth\AuthController@getLogout');// Registration routes...Route::get('auth/register', 'Auth\AuthController@getRegister');Route::post('auth/register', 'Auth\AuthController@postRegister');

注意:上面的需要对应的视图。
可以通过

protected $redirectPath = '/url';

修改验证完成的跳转地址。
可以修改登录位置:

protected $loginPath = '/login';

但是如果上面的验证是通过中间件的方式执行的,配置不起作用

接收认证用户:
$user = Auth::user(); 单独使用这个,就是 facade 。

也可以通过

public function updateProfile(Request $request){     if($user->user()){     }}

检测当前用户是否已经被验证:

if(Auth::check()){}

Auth 认证,单独作用于固定的路由。

middleware=>'auth'

或者控制器下使用:

$this->middleware('auth');

认证登录限制,如果失败,登录限制。
手工认证客户:

0 0
原创粉丝点击