first commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Session;
|
||||
|
||||
class BackendController extends Controller
|
||||
{
|
||||
public function login () {
|
||||
return view('backend.login');
|
||||
}
|
||||
|
||||
public function loginAdmin (Request $request) {
|
||||
$request->validate([
|
||||
'email'=>'required',
|
||||
'password' => 'required'
|
||||
], [
|
||||
'email.required' => 'Nhập tên đăng nhập',
|
||||
'password.required' => 'Nhập mật khẩu'
|
||||
]);
|
||||
|
||||
$login = [
|
||||
'email' => $request->email,
|
||||
'password' => $request->password,
|
||||
'status' => 1
|
||||
];
|
||||
if (Auth::attempt($login)) {
|
||||
session_start();
|
||||
$_SESSION['IsAuthorized'] = true;
|
||||
return redirect()->route('admin/account')->withCookie(cookie()->forever('allowCkfinder', "1"));;
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Email hoặc Password không chính xác');
|
||||
}
|
||||
}
|
||||
|
||||
public function account () {
|
||||
$title = 'Thông tin tài khoản';
|
||||
$data = User::find(Auth::user()->id);
|
||||
return view('backend.user.account')->with('data', $data)->with('title', $title);
|
||||
}
|
||||
|
||||
public function logout () {
|
||||
Auth::logout();
|
||||
return redirect('/wp-admin');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user