1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thinkstudeo\Rakshak\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use Illuminate\Support\Facades\Cache; |
7
|
|
|
use Thinkstudeo\Rakshak\RakshakSetting; |
8
|
|
|
|
9
|
|
|
class RakshakSettingsController extends Controller |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Show the form for editing the specified resource. |
13
|
|
|
* |
14
|
|
|
* @param User $user |
|
|
|
|
15
|
|
|
* @return \Illuminate\Http\Response |
16
|
|
|
*/ |
17
|
|
|
public function edit() |
18
|
|
|
{ |
19
|
|
|
$setting = RakshakSetting::first(); |
20
|
|
|
$this->authorize('update', $setting); |
21
|
|
|
|
22
|
|
|
return view('rakshak::settings.edit', compact('setting')); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Update the specified resource in storage. |
27
|
|
|
* |
28
|
|
|
* @param \Illuminate\Http\Request $request |
29
|
|
|
* @return \Illuminate\Http\Response |
30
|
|
|
*/ |
31
|
|
|
public function update(Request $request) |
32
|
|
|
{ |
33
|
|
|
$setting = RakshakSetting::first(); |
34
|
|
|
$this->authorize('update', $setting); |
35
|
|
|
|
36
|
|
|
$validated = $request->validate([ |
37
|
|
|
'enable_2fa' => ['required', 'boolean'], |
38
|
|
|
'channel_2fa' => ['required', 'in:email,sms'], |
39
|
|
|
'control_level_2fa' => ['required', 'in:admin,user'], |
40
|
|
|
]); |
41
|
|
|
|
42
|
|
|
$setting = tap($setting)->update($validated); |
43
|
|
|
$this->updateCache($setting); |
44
|
|
|
|
45
|
|
|
if ($request->expectsJson()) { |
46
|
|
|
return response(['message' => 'Rakshak settings updated successfully!', 'record' => $setting], 200); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return redirect() |
|
|
|
|
50
|
|
|
->back() |
51
|
|
|
->with('status', 'success') |
52
|
|
|
->with('message', 'Rakshak settings updated successfully.'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Update the values for the cache keys. |
57
|
|
|
* |
58
|
|
|
* @param RakshakSetting $setting |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
protected function updateCache($setting) |
62
|
|
|
{ |
63
|
|
|
Cache::forever('rakshak.enable_2fa', $setting->enable_2fa); |
64
|
|
|
Cache::forever('rakshak.channel_2fa', $setting->channel_2fa); |
65
|
|
|
Cache::forever('rakshak.control_level_2fa', $setting->control_level_2fa); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
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