-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflash.php
39 lines (30 loc) · 876 Bytes
/
flash.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SessionsController extends Controller
{
public function __construct()
{
$this->middleware('guest')->except('destroy');
}
public function create()
{
return view('sessions.create');
}
public function store()
{
if (auth()->attempt(request(['email', 'password'])) == false) {
return back()->withErrors([
'message' => 'The email or password is incorrect, please try again'
]);
}
session()->flash('message', '<b>Nice!</b> You are now logged in');
session()->flash('type', 'success');
return redirect()->to('/games');
}
public function destroy()
{
auth()->logout();
return redirect()->to('/games');
}
}