slink/laravel/app/Http/Controllers/LoginController.php

25 lines
640 B
PHP
Raw Normal View History

2024-06-09 22:03:34 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller {
public function login(Request $request) {
$credentials = $request->validate([
'email' => 'required|email|string',
'password' => 'required|string',
]);
if (Auth::attempt($credentials, $remember = false)) {
$request->session()->regenerate();
return redirect('/profile');
}
return back()->withErrors([
'email' => 'The provided credentials do not match our records.',
]);
}
}