TurkMvc Laravel'de Auth dediğiniz şu:
- İçinde login ve logout yöntemi olan bir tane controller
- Login formu
Şu controller
class LoginController extends Controller
{
public function login(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);
if (Auth::attempt($credentials)) {
$request->session()
->regenerate();
return redirect()->intended('admin');
}
abort(401, __('Invalid credentials'))
}
public function logout(Request $request)
{
Auth::logout();
$request->session()
->invalidate();
$request->session()
->regenerateToken();
return redirect('/');
}
}
Şu da form:
<form action="{{ route('login') }}" method="POST">
@csrf
<input type="text" id="email" name="email" required>
<input type="password" id="password" name="password" required>
<button type="submit">{{ __('Login') }}</button>
</form>