You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
42 lines
871 B
42 lines
871 B
<?php |
|
|
|
namespace App\Http\Controllers; |
|
|
|
use Illuminate\Http\Request; |
|
use Hash; |
|
use Session; |
|
use App\Models\User; |
|
use Illuminate\Support\Facades\Auth; |
|
|
|
class LoginController extends Controller |
|
{ |
|
public function index() |
|
{ |
|
return view('auth.login'); |
|
} |
|
|
|
public function login() |
|
{ |
|
request()->validate([ |
|
'email' => 'required|email', |
|
'password' => 'required|min:4|max:20', |
|
]); |
|
|
|
if (auth()->attempt([ |
|
'email' => request('email'), |
|
'password' => request('password') |
|
])) { |
|
return redirect()->intended('/'); |
|
} |
|
|
|
return back()->withErrors([ |
|
'email' => 'The provided credentials do not match our records.', |
|
]); |
|
} |
|
|
|
public function logout() |
|
{ |
|
auth()->logout(); |
|
return redirect('/login'); |
|
} |
|
}
|
|
|