Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Mar 14, 2024
1 parent 1314ab9 commit c8ed2da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 0 additions & 12 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\PasswordRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -17,17 +16,6 @@ public function update(PasswordRequest $request): Response
{
$validated = $request->validated();

if (! Auth::attempt([
'email' => $request->user()->email,
'password' => $validated['current_password'],
])) {
$errors = ['current_password' => trans('auth.failed')];

return $request->expectsJson()
? response()->json(['message' => $errors['current_password'], 'errors' => $errors], 400)
: back()->withErrors($errors);
}

$request->user()->update([
'password' => Hash::make($validated['password']),
]);
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Requests/Auth/PasswordRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class PasswordRequest extends FormRequest
{
use PasswordValidationRules;

/**
* The key to be used for the view error bag.
*
* @var string
*/
protected $errorBag = 'updatePassword';

/**
* Determine if the user is authorized to make this request.
*/
Expand All @@ -25,7 +32,7 @@ public function authorize(): bool
public function rules(): array
{
return [
'current_password' => 'required|string',
'current_password' => 'required|string|current_password',
'password' => $this->passwordRules(),
];
}
Expand Down

0 comments on commit c8ed2da

Please sign in to comment.