1 | <?php namespace crocodicstudio\crudbooster\controllers; |
||||
2 | |||||
3 | use CRUDBooster; |
||||
0 ignored issues
–
show
|
|||||
4 | use Illuminate\Support\Facades\DB; |
||||
5 | use Illuminate\Support\Facades\Request; |
||||
6 | use Illuminate\Support\Facades\Session; |
||||
7 | use Illuminate\Support\Facades\Validator; |
||||
8 | |||||
9 | class AdminController extends CBController |
||||
10 | { |
||||
11 | function getIndex() |
||||
0 ignored issues
–
show
|
|||||
12 | { |
||||
13 | $data = []; |
||||
14 | $data['page_title'] = '<strong>Dashboard</strong>'; |
||||
15 | |||||
16 | return view('crudbooster::home', $data); |
||||
17 | } |
||||
18 | |||||
19 | public function getLockscreen() |
||||
20 | { |
||||
21 | |||||
22 | if (! CRUDBooster::myId()) { |
||||
23 | Session::flush(); |
||||
24 | |||||
25 | return redirect()->route('getLogin')->with('message', trans('crudbooster.alert_session_expired')); |
||||
26 | } |
||||
27 | |||||
28 | Session::put('admin_lock', 1); |
||||
29 | |||||
30 | return view('crudbooster::lockscreen'); |
||||
31 | } |
||||
32 | |||||
33 | public function postUnlockScreen() |
||||
34 | { |
||||
35 | $id = CRUDBooster::myId(); |
||||
36 | $password = Request::input('password'); |
||||
37 | $users = DB::table(config('crudbooster.USER_TABLE'))->where('id', $id)->first(); |
||||
38 | |||||
39 | if (\Hash::check($password, $users->password)) { |
||||
40 | Session::put('admin_lock', 0); |
||||
41 | |||||
42 | return redirect(CRUDBooster::adminPath()); |
||||
43 | } else { |
||||
44 | echo "<script>alert('".trans('crudbooster.alert_password_wrong')."');history.go(-1);</script>"; |
||||
0 ignored issues
–
show
Are you sure
trans('crudbooster.alert_password_wrong') of type array|string can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
45 | } |
||||
46 | } |
||||
47 | |||||
48 | public function getLogin() |
||||
49 | { |
||||
50 | |||||
51 | if (CRUDBooster::myId()) { |
||||
52 | return redirect(CRUDBooster::adminPath()); |
||||
53 | } |
||||
54 | |||||
55 | return view('crudbooster::login'); |
||||
56 | } |
||||
57 | |||||
58 | public function postLogin() |
||||
59 | { |
||||
60 | |||||
61 | $validator = Validator::make(Request::all(), [ |
||||
62 | 'email' => 'required|email|exists:'.config('crudbooster.USER_TABLE'), |
||||
63 | 'password' => 'required', |
||||
64 | ]); |
||||
65 | |||||
66 | if ($validator->fails()) { |
||||
67 | $message = $validator->errors()->all(); |
||||
68 | |||||
69 | return redirect()->back()->with(['message' => implode(', ', $message), 'message_type' => 'danger']); |
||||
70 | } |
||||
71 | |||||
72 | $email = Request::input("email"); |
||||
73 | $password = Request::input("password"); |
||||
74 | $users = DB::table(config('crudbooster.USER_TABLE'))->where("email", $email)->first(); |
||||
75 | |||||
76 | if (\Hash::check($password, $users->password)) { |
||||
77 | $priv = DB::table("cms_privileges")->where("id", $users->id_cms_privileges)->first(); |
||||
78 | |||||
79 | $roles = DB::table('cms_privileges_roles')->where('id_cms_privileges', $users->id_cms_privileges)->join('cms_moduls', 'cms_moduls.id', '=', 'id_cms_moduls')->select('cms_moduls.name', 'cms_moduls.path', 'is_visible', 'is_create', 'is_read', 'is_edit', 'is_delete')->get(); |
||||
80 | |||||
81 | $photo = ($users->photo) ? asset($users->photo) : asset('vendor/crudbooster/avatar.jpg'); |
||||
82 | Session::put('admin_id', $users->id); |
||||
83 | Session::put('admin_is_superadmin', $priv->is_superadmin); |
||||
84 | Session::put('admin_name', $users->name); |
||||
85 | Session::put('admin_photo', $photo); |
||||
86 | Session::put('admin_privileges_roles', $roles); |
||||
87 | Session::put("admin_privileges", $users->id_cms_privileges); |
||||
88 | Session::put('admin_privileges_name', $priv->name); |
||||
89 | Session::put('admin_lock', 0); |
||||
90 | Session::put('theme_color', $priv->theme_color); |
||||
91 | Session::put("appname", CRUDBooster::getSetting('appname')); |
||||
92 | |||||
93 | CRUDBooster::insertLog(trans("crudbooster.log_login", ['email' => $users->email, 'ip' => Request::server('REMOTE_ADDR')])); |
||||
94 | |||||
95 | $cb_hook_session = new \App\Http\Controllers\CBHook; |
||||
96 | $cb_hook_session->afterLogin(); |
||||
97 | |||||
98 | return redirect(CRUDBooster::adminPath()); |
||||
99 | } else { |
||||
100 | return redirect()->route('getLogin')->with('message', trans('crudbooster.alert_password_wrong')); |
||||
101 | } |
||||
102 | } |
||||
103 | |||||
104 | public function getForgot() |
||||
105 | { |
||||
106 | if (CRUDBooster::myId()) { |
||||
107 | return redirect(CRUDBooster::adminPath()); |
||||
108 | } |
||||
109 | |||||
110 | return view('crudbooster::forgot'); |
||||
111 | } |
||||
112 | |||||
113 | public function postForgot() |
||||
114 | { |
||||
115 | $validator = Validator::make(Request::all(), [ |
||||
116 | 'email' => 'required|email|exists:'.config('crudbooster.USER_TABLE'), |
||||
117 | ]); |
||||
118 | |||||
119 | if ($validator->fails()) { |
||||
120 | $message = $validator->errors()->all(); |
||||
121 | |||||
122 | return redirect()->back()->with(['message' => implode(', ', $message), 'message_type' => 'danger']); |
||||
123 | } |
||||
124 | |||||
125 | $rand_string = str_random(5); |
||||
0 ignored issues
–
show
The function
str_random() has been deprecated: Str::random() should be used directly instead. Will be removed in Laravel 6.0.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
126 | $password = \Hash::make($rand_string); |
||||
127 | |||||
128 | DB::table(config('crudbooster.USER_TABLE'))->where('email', Request::input('email'))->update(['password' => $password]); |
||||
129 | |||||
130 | $appname = CRUDBooster::getSetting('appname'); |
||||
0 ignored issues
–
show
|
|||||
131 | $user = CRUDBooster::first(config('crudbooster.USER_TABLE'), ['email' => g('email')]); |
||||
132 | $user->password = $rand_string; |
||||
133 | CRUDBooster::sendEmail(['to' => $user->email, 'data' => $user, 'template' => 'forgot_password_backend']); |
||||
134 | |||||
135 | CRUDBooster::insertLog(trans("crudbooster.log_forgot", ['email' => g('email'), 'ip' => Request::server('REMOTE_ADDR')])); |
||||
136 | |||||
137 | return redirect()->route('getLogin')->with('message', trans("crudbooster.message_forgot_password")); |
||||
138 | } |
||||
139 | |||||
140 | public function getLogout() |
||||
141 | { |
||||
142 | |||||
143 | $me = CRUDBooster::me(); |
||||
144 | CRUDBooster::insertLog(trans("crudbooster.log_logout", ['email' => $me->email])); |
||||
145 | |||||
146 | Session::flush(); |
||||
147 | |||||
148 | return redirect()->route('getLogin')->with('message', trans("crudbooster.message_after_logout")); |
||||
149 | } |
||||
150 | } |
||||
151 |
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