auth('customer')->user(), ]); } public function update(Request $request): RedirectResponse { $customer = auth('customer')->user(); $throttleKey = 'portal-profile|' . $customer->id; if (RateLimiter::tooManyAttempts($throttleKey, 10)) { $seconds = RateLimiter::availableIn($throttleKey); throw ValidationException::withMessages([ 'email' => __('auth.throttle', ['seconds' => $seconds]), ]); } RateLimiter::hit($throttleKey, 3600); $validated = $request->validate([ 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique('customers')->ignore($customer->id)], 'locale' => ['required', 'in:de,en'], 'current_password' => ['nullable', 'required_with:password', 'current_password:customer'], 'password' => ['nullable', 'confirmed', Password::defaults()], ]); $customer->email = $validated['email']; $customer->locale = $validated['locale']; $emailChanged = $customer->isDirty('email'); $oldEmail = $customer->getOriginal('email'); if ($request->filled('password')) { $customer->password = $validated['password']; } $customer->save(); RateLimiter::clear($throttleKey); if ($emailChanged) { $admin = User::first(); if ($admin) { Mail::to($admin)->send(new CustomerEmailChangedMail($customer, $oldEmail, $validated['email'])); } } App::setLocale($customer->locale); session(['locale' => $customer->locale]); return redirect()->back()->with('success', __('portal.profile_saved')); } }