|
1
|
|
|
<?php namespace Arcanesoft\Auth\Http\Controllers\Foundation; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Auth\Bases\FoundationController; |
|
4
|
|
|
use Arcanesoft\Auth\Http\Requests\Backend\Profile\UpdatePasswordRequest; |
|
5
|
|
|
use Arcanesoft\Contracts\Auth\Models\User; |
|
6
|
|
|
use Log; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class ProfileController |
|
10
|
|
|
* |
|
11
|
|
|
* @package Arcanesoft\Auth\Http\Controllers\Foundation |
|
12
|
|
|
* @author ARCANEDEV <[email protected]> |
|
13
|
|
|
* |
|
14
|
|
|
* @todo: Adding the authorization checks |
|
15
|
|
|
*/ |
|
16
|
|
|
class ProfileController extends FoundationController |
|
17
|
|
|
{ |
|
18
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
19
|
|
|
| Properties |
|
20
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
21
|
|
|
*/ |
|
22
|
|
|
/** |
|
23
|
|
|
* The authenticated user. |
|
24
|
|
|
* |
|
25
|
|
|
* @var \Arcanesoft\Contracts\Auth\Models\User |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $user; |
|
28
|
|
|
|
|
29
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
30
|
|
|
| Constructor |
|
31
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
32
|
|
|
*/ |
|
33
|
|
|
/** |
|
34
|
|
|
* ProfileController constructor. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct() |
|
37
|
|
|
{ |
|
38
|
|
|
parent::__construct(); |
|
39
|
|
|
|
|
40
|
|
|
$this->user = auth()->user(); |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$this->setCurrentPage('auth-profile'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
46
|
|
|
| Main Functions |
|
47
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
48
|
|
|
*/ |
|
49
|
|
|
public function index() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->setData('user', $this->user); |
|
52
|
|
|
|
|
53
|
|
|
$title = 'Profile - ' . $this->user->full_name; |
|
|
|
|
|
|
54
|
|
|
$this->setTitle($title); |
|
55
|
|
|
$this->addBreadcrumbRoute($title, 'auth::foundation.profile.index'); |
|
56
|
|
|
|
|
57
|
|
|
return $this->view('foundation.profile.index'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function updatePassword(UpdatePasswordRequest $request, User $user) |
|
61
|
|
|
{ |
|
62
|
|
|
$user->password = $request->get('password'); |
|
|
|
|
|
|
63
|
|
|
$user->save(); |
|
64
|
|
|
|
|
65
|
|
|
$message = "The password was updated successfully !"; |
|
66
|
|
|
Log::info($message, $user->toArray()); |
|
67
|
|
|
$this->notifySuccess($message, 'Password Updated !'); |
|
68
|
|
|
|
|
69
|
|
|
return redirect()->route('auth::foundation.profile.index'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.