user); } public function update(ProfileUpdateRequest $request) { static::disableInDemo(Response::HTTP_NO_CONTENT); // If the user is not using SSO, we need to verify their current password. throw_if( !$this->user->is_sso && !$this->hash->check($request->current_password, $this->user->password), ValidationException::withMessages(['current_password' => 'Invalid current password']) ); $user = $this->userService->updateUser( user: $this->user, name: $request->name, email: $request->email, password: $request->new_password, avatar: Str::startsWith($request->avatar, 'data:') ? $request->avatar : null ); $response = UserResource::make($user)->response(); if ($request->new_password) { $response->header( 'Authorization', $this->tokenManager->refreshApiToken($request->bearerToken() ?: '')->plainTextToken ); } return $response; } }