1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\URL; |
6
|
|
|
use Illuminate\Support\Facades\Auth; |
7
|
|
|
use Illuminate\Http\RedirectResponse; |
8
|
|
|
use Illuminate\Support\Facades\View; |
9
|
|
|
use Terranet\Administrator\Architect; |
10
|
|
|
use Illuminate\Support\Facades\Redirect; |
11
|
|
|
use Terranet\Administrator\Requests\LoginRequest; |
12
|
|
|
use Illuminate\Contracts\View\View as ViewContract; |
13
|
|
|
use App\Http\Controllers\Controller as BaseController; |
|
|
|
|
14
|
|
|
|
15
|
|
|
class AuthController extends BaseController |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param LoginRequest $request |
19
|
2 |
|
* @return RedirectResponse |
20
|
|
|
*/ |
21
|
2 |
|
public function postLogin(LoginRequest $request) |
22
|
|
|
{ |
23
|
|
|
$config = app('scaffold.config'); |
|
|
|
|
24
|
2 |
|
|
25
|
|
|
// basic login policy |
26
|
2 |
|
$credentials = $request->only( |
27
|
2 |
|
[ |
28
|
|
|
$config->get('auth.identity', 'username'), |
29
|
|
|
$config->get('auth.credential', 'password'), |
30
|
|
|
] |
31
|
|
|
); |
32
|
2 |
|
|
33
|
2 |
|
// extend auth policy by allowing custom login conditions |
34
|
|
|
if ($conditions = $config->get('auth.conditions', [])) { |
35
|
|
|
$credentials = array_merge($credentials, $conditions); |
36
|
2 |
|
} |
37
|
|
|
|
38
|
2 |
|
$remember = (int) $request->get('remember_me', 0); |
39
|
1 |
|
|
40
|
1 |
|
if ($this->guard()->attempt($credentials, $remember, true)) { |
41
|
|
|
if (\is_callable($url = $config->get('home_page'))) { |
42
|
|
|
$url = \call_user_func($url); |
43
|
1 |
|
} |
44
|
|
|
|
45
|
|
|
return Redirect::to(URL::to($url)); |
46
|
1 |
|
} |
47
|
|
|
|
48
|
|
|
return Redirect::back()->withErrors([trans('administrator::errors.login_failed')]); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
1 |
|
* @return ViewContract |
53
|
|
|
*/ |
54
|
1 |
|
public function getLogin(): ViewContract |
55
|
1 |
|
{ |
56
|
|
|
return View::make( |
57
|
|
|
Architect::template()->auth('login') |
|
|
|
|
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
1 |
|
* @return RedirectResponse |
63
|
|
|
*/ |
64
|
1 |
|
public function getLogout() |
65
|
|
|
{ |
66
|
1 |
|
$this->guard()->logout(); |
67
|
1 |
|
|
68
|
|
|
return Redirect::to( |
69
|
|
|
URL::route('scaffold.login') |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return mixed |
75
|
|
|
*/ |
76
|
|
|
protected function guard() |
77
|
|
|
{ |
78
|
|
|
return Auth::guard('admin'); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths