You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
PHTML
49 lines
1.1 KiB
PHTML
1 year ago
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Support\Facades\Auth;
|
||
|
use Symfony\Component\HttpFoundation\Response;
|
||
|
|
||
|
class AuthController extends Controller
|
||
|
{
|
||
|
public function showLogin(Request $request)
|
||
|
{
|
||
|
//$token = $request->session()->token();
|
||
|
|
||
|
//$token = csrf_token();
|
||
|
return view('front.login');
|
||
|
}
|
||
|
|
||
|
public function memberAuth(Request $request): Response
|
||
|
{
|
||
|
$token = csrf_token();
|
||
|
|
||
|
$credentials = $request->validate([
|
||
|
'handle' => ['required'],
|
||
|
'password' => ['required'],
|
||
|
]);
|
||
|
|
||
|
if (Auth::attempt($credentials)) {
|
||
|
$request->session()->regenerate();
|
||
|
return redirect()->intended('den');
|
||
|
}
|
||
|
|
||
|
return back()->withErrors([
|
||
|
'error' => 'Nope. Check your crendtials, champ',
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
public function leave(Request $request): Response
|
||
|
{
|
||
|
Auth::logout();
|
||
|
|
||
|
$request->session()->invalidate();
|
||
|
|
||
|
$request->session()->regenerateToken();
|
||
|
|
||
|
return redirect()->intended('login');
|
||
|
}
|
||
|
}
|