|
1
|
|
|
<?php |
|
2
|
|
|
namespace Afrittella\BackProject\Http\Controllers\Auth; |
|
3
|
|
|
|
|
4
|
|
|
//use Afrittella\BackProject\app\Http\Controllers\Controller; |
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
|
|
9
|
|
|
class LoginController extends Controller |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
use AuthenticatesUsers { |
|
13
|
|
|
logout as defaultLogout; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function __construct() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->middleware('guest', ['except' => 'logout']); |
|
19
|
|
|
// ---------------------------------- |
|
20
|
|
|
// Use the admin prefix in all routes |
|
21
|
|
|
// If not logged in redirect here. |
|
22
|
|
|
$this->loginPath = property_exists($this, 'loginPath') ? $this->loginPath |
|
23
|
|
|
: config('back-project.route_prefix', 'admin').'/login'; |
|
24
|
|
|
// Redirect here after successful login. |
|
25
|
|
|
$this->redirectTo = property_exists($this, 'redirectTo') ? $this->redirectTo |
|
26
|
|
|
: config('back-project.route_prefix', 'admin').'/dashboard'; |
|
27
|
|
|
// Redirect here after logout. |
|
28
|
|
|
$this->redirectAfterLogout = property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout |
|
29
|
|
|
: '/'; |
|
30
|
|
|
// ---------------------------------- |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Show the application login form. |
|
35
|
|
|
* |
|
36
|
|
|
* @return \Illuminate\Http\Response |
|
37
|
|
|
*/ |
|
38
|
|
|
public function showLoginForm() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->data['title'] = trans('back-project::base.login'); // set the page title |
|
41
|
|
|
return view('back-project::auth.login', $this->data); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Log the user out and redirect him to specific location. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \Illuminate\Http\Request $request |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Illuminate\Http\Response |
|
50
|
|
|
*/ |
|
51
|
|
|
public function logout(Request $request) |
|
52
|
|
|
{ |
|
53
|
|
|
// Do the default logout procedure |
|
54
|
|
|
$this->defaultLogout($request); |
|
55
|
|
|
// And redirect to custom location |
|
56
|
|
|
return redirect($this->redirectAfterLogout); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get the needed authorization credentials from the request. |
|
61
|
|
|
* |
|
62
|
|
|
* @param \Illuminate\Http\Request $request |
|
63
|
|
|
* @return array |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function credentials(Request $request) |
|
66
|
|
|
{ |
|
67
|
|
|
return array_merge($request->only($this->username(), 'password'), ['confirmed' => 1, 'is_social' => 0]); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|