/
AuthController.php
49 lines (42 loc) · 1.38 KB
/
AuthController.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
40
41
42
43
44
45
46
47
48
49
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mockery\Exception;
class AuthController extends Controller
{
public function login()
{
$title = 'Login to your account';
return view('auth.login', compact('title'));
}
public function postLogin(Request $request)
{
$data = $request->all();
try{
if (auth()->attempt(['email' => $data['email'], 'password' => $data['password'], 'is_active' => true])) {
if (auth()->user()->user_type == 1 || auth()->user()->user_type == 2)
{
return redirect()->intended(route('home'));
}
elseif(auth()->user()->user_type == 3)
{
return redirect()->intended(route('home'));
}
elseif(auth()->user()->user_type == 4)
{
return 'Parent';
}
}
return redirect()->back()->with('error', 'Identification No and Password Combination Incorrect')->withInput();
} catch (\Exception $e)
{
/*Send us a mail */
return redirect()->back()->with('error', 'Could not sign you in at the moment. Please try again...');
}
}
public function logout()
{
auth()->logout();
return redirect()->route('login');
}
}