mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 02:50:39 +00:00
added current password to the password changing form
This commit is contained in:
@@ -14,7 +14,7 @@ class UpdatePasswordController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
abort_if(is_demo_account($user->email), 204, 'Changed!');
|
||||
abort_if(is_demo_account(), 204, 'Changed!');
|
||||
|
||||
// Store new password
|
||||
$user->update([
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace App\Users\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Users\Rules\PasswordMatchWithCurrent;
|
||||
|
||||
class UpdateUserPasswordRequest extends FormRequest
|
||||
{
|
||||
@@ -23,6 +24,7 @@ class UpdateUserPasswordRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'current' => ['required', 'string', new PasswordMatchWithCurrent()],
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace App\Users\Rules;
|
||||
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class PasswordMatchWithCurrent implements Rule
|
||||
{
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*/
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
return Hash::check($value, Auth::user()->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*/
|
||||
public function message(): string
|
||||
{
|
||||
return "Your current password doesn't match.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user