| xqd
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin\Auth;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
|
|
use Validator, Auth;
|
|
|
+use App\Services\Admin\AdminUser;
|
|
|
|
|
|
class LoginController extends Controller
|
|
|
{
|
| xqd
@@ -33,8 +34,10 @@ class LoginController extends Controller
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
+ private $_service;
|
|
|
public function __construct()
|
|
|
{
|
|
|
+ $this->_service = new AdminUser();
|
|
|
$this->middleware('guest', ['except' => 'logout']);
|
|
|
}
|
|
|
/**
|
| xqd
@@ -80,6 +83,14 @@ class LoginController extends Controller
|
|
|
$msg = $validator->messages()->first();
|
|
|
return $this->showWarning($msg);
|
|
|
}
|
|
|
+ $ok = $this->_service->login($request->name, $request->password);
|
|
|
+ if($ok) {
|
|
|
+ return redirect("/admin");
|
|
|
+ }else{
|
|
|
+ $msg = $this->_service->getMsg();
|
|
|
+ $this->showWarning($msg);
|
|
|
+ }
|
|
|
+
|
|
|
if (!Auth::guard('admin')->attempt(['name' => $request->name, 'password' => $request->password])){
|
|
|
return $this->showMessage('用户名或密码错误!');
|
|
|
}
|