Laravel 5.2服务----用户验证Auth相关问题

关于laravel的auth()用户认证这一块,面前我也是,有用到,有碰到什么问题我就记录下来。

手动认证用户

<?php

namespace AppHttpControllers;

use Auth;
use IlluminateRoutingController;

class AuthController extends Controller{
    /**
     * 处理登录认证
     *
     * @return Response
     */
    public function authenticate()
    {
        if (Auth::attempt(['email' => $email, 'password' => $password])) {
            // 认证通过...
            return redirect()->intended('dashboard');
        }
    }
}
一次性认证用户

once 方法只在单个请求中将用户登录到应用,而不存储任何 Session 和 Cookie,这在构建无状态的 API 时很有用。once方法和attempt方法用法差不多:

if (Auth::once($credentials)) {
    //
}
原文地址:https://www.cnblogs.com/smallyi/p/6526694.html