Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | 6 | public function setPolicy($request) |
|
11 | { |
||
12 | // Update the main policy |
||
13 | 6 | $this->updateSettings('auth.passwords.settings.expire', $request->expire); |
|
14 | |||
15 | // Update all users to reflect the new policy |
||
16 | 6 | if($request->expire == 0) |
|
17 | { |
||
18 | 2 | User::where('password_expires', '>', NOW())->update([ |
|
19 | 2 | 'password_expires' => null, |
|
20 | ]); |
||
21 | } |
||
22 | else |
||
23 | { |
||
24 | 4 | $newExpire = Carbon::now()->addDays($request->expire); |
|
25 | 4 | User::whereNull('password_expires')->update([ |
|
26 | 4 | 'password_expires' => $newExpire, |
|
27 | ]); |
||
28 | } |
||
29 | |||
30 | 6 | return true; |
|
31 | } |
||
33 |