1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Containers\Authentication\UI\WEB\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Containers\Authentication\Actions\WebAdminLoginAction; |
6
|
|
|
use App\Containers\Authentication\Actions\WebLogoutAction; |
7
|
|
|
use App\Containers\Authentication\UI\WEB\Requests\LoginRequest; |
8
|
|
|
use App\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest; |
9
|
|
|
use App\Port\Controller\Abstracts\PortWebController; |
10
|
|
|
|
11
|
|
|
use App\Containers\Authentication\Exceptions\AuthenticationFailedException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Controller |
15
|
|
|
* |
16
|
|
|
* @author Mahmoud Zalt <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class Controller extends PortWebController |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
23
|
|
|
*/ |
24
|
|
|
public function showLoginPage() |
25
|
|
|
{ |
26
|
|
|
return view('login'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param \App\Containers\Authentication\UI\WEB\Requests\LoginRequest $request |
31
|
|
|
* @param \App\Containers\Authentication\Actions\WebAdminLoginAction $action |
32
|
|
|
* |
33
|
|
|
* @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View |
34
|
|
|
*/ |
35
|
|
|
public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action) |
36
|
|
|
{ |
37
|
|
|
try { |
38
|
|
|
$result = $action->run($request->email, $request->password, $request->remember_me); |
|
|
|
|
39
|
|
|
} catch (AuthenticationFailedException $e) { |
40
|
|
|
return redirect('/login')->with('status', $e->message); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
if (is_array($result)) { |
44
|
|
|
return redirect('/login')->with($result); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return redirect('/dashboard'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param \App\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest $request |
52
|
|
|
* |
53
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
54
|
|
|
*/ |
55
|
|
|
public function viewDashboardPage(ViewDashboardRequest $request) |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
return view('dashboard'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param \App\Containers\Authentication\Actions\WebLogoutAction $action |
62
|
|
|
* |
63
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
64
|
|
|
*/ |
65
|
|
|
public function logoutAdmin(WebLogoutAction $action) |
66
|
|
|
{ |
67
|
|
|
$action->run(); |
68
|
|
|
|
69
|
|
|
return view('login'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.