ChangePasswordController::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
nc 1
nop 1
dl 0
loc 13
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Http\Controllers\Auth;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\Hash;
7
use Illuminate\Support\Str;
8
use Thinktomorrow\Chief\App\Http\Controllers\Controller;
9
10
class ChangePasswordController extends Controller
11
{
12
    /**
13
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
14
     */
15
    public function edit()
16
    {
17
        $user = auth()->guard('chief')->user();
18
19
        return view('chief::admin.auth.passwords.edit', ['new_password' => ! $user->password]);
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
20
    }
21
22
    public function update(Request $request)
23
    {
24
        $this->validate($request, [
25
            'password' => 'required|confirmed|min:6',
26
        ]);
27
28
        $user = auth()->guard('chief')->user();
29
30
        $user->password = Hash::make($request->password);
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
31
        $user->setRememberToken(Str::random(60));
32
        $user->save();
33
34
        return redirect()->route('chief.back.dashboard')->with('messages.success', 'Jouw wachtwoord is aangepast.');
35
    }
36
}
37