标签:stat redirect ali app cat pac result ext 用户认证
<?php namespace App\Model; use Illuminate\Database\Eloquent\Model; class Manager extends Model implements \Illuminate\Contracts\Auth\Authenticatable { use \Illuminate\Auth\Authenticatable; protected $table = ‘manager‘; }
public function check(Request $request) { if ($request->method() == ‘POST‘) { //判断验证码是否正确 $this->validate($request, [ ‘captcha‘ => ‘required|captcha‘ ]); } $data = $request->only([‘username‘, ‘password‘]); $data[‘status‘] = 1; //用户认证 $result = \Auth::guard(‘admin‘)->attempt($data, $request->get(‘online‘)); if ($result) { //成功 跳转到后台首页 return redirect(‘/admin/index/index‘); } else { //失败 跳转回登录也 return redirect(‘/admin/public/login‘)->withErrors([ ‘loginError‘ => ‘用户名或密码错误。‘ ]); } } public function logout() { \Auth::guard(‘admin‘)->logout(); return redirect(‘/admin/public/login‘); }
\Auth::guard(‘admin‘)->user()
标签:stat redirect ali app cat pac result ext 用户认证
原文地址:https://www.cnblogs.com/jxl1996/p/10269359.html