authorize('manageOwnProfile', Customer::class); return view('fo.customer.edit.password'); } public function editPasswordSubmit(UpdatePasswordRequest $request): RedirectResponse { $this->authorize('manageOwnProfile', Customer::class); $customer = $this->authService->getCustomerAsMandatory(); $crmCustomer = $this->crmService->getCustomerFromHashCode($customer->hashcode); if (! $crmCustomer instanceof CrmCustomer) { return back()->withErrors(trans('An error occurred, please try again later.')); } try { $result = $this->crmService->changePassword( $crmCustomer, $request->string('password_old')->value(), $request->string('password')->value() ); if ($result instanceof CrmCustomer) { return back()->with('success', trans('Password updated')); } return back()->withErrors($result->errors()); } catch (\Throwable $e) { report($e); return back()->withErrors(trans('An error occurred, please try again later.')); } } }