Skip to content

Commit

Permalink
fix(api): save user email on the first try (#760)
Browse files Browse the repository at this point in the history
* fix(api): save user email on the first try

fix #227

* fix(api): remove todo

* fix(logging): handle media server connection refused error/toast (#748)

* fix(logging): handle media server connection refused error/toast

Properly log as connection refused if the jellyfin/emby server is unreachable. Previously it used to
throw a credentials error which lead to a lot of confusion

* refactor(i8n): extract translation keys

* refactor(auth): error message for a more consistent format

* refactor(auth/errors): use custom error types and error codes instead of abusing error messages

* refactor(i8n): replace connection refused translation key with invalidurl

* fix(error): combine auth and api error class into a single one called network error

* fix(error): use the new network error and network error codes in auth/api

* refactor(error): rename NetworkError to ApiError

---------

Co-authored-by: Fallenbagel <98979876+Fallenbagel@users.noreply.github.com>
  • Loading branch information
gauthier-th and Fallenbagel committed May 23, 2024
1 parent f486fb5 commit 0bbcfdc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server/routes/user/usersettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ userSettingsRoutes.post<
}

user.username = req.body.username;
user.email = req.body.email ?? user.email;

// Update quota values only if the user has the correct permissions
if (
Expand Down Expand Up @@ -127,20 +128,19 @@ userSettingsRoutes.post<
user.settings.originalLanguage = req.body.originalLanguage;
user.settings.watchlistSyncMovies = req.body.watchlistSyncMovies;
user.settings.watchlistSyncTv = req.body.watchlistSyncTv;
user.email = req.body.email ?? user.email;
}

await userRepository.save(user);
const savedUser = await userRepository.save(user);

return res.status(200).json({
username: user.username,
discordId: user.settings.discordId,
locale: user.settings.locale,
region: user.settings.region,
originalLanguage: user.settings.originalLanguage,
watchlistSyncMovies: user.settings.watchlistSyncMovies,
watchlistSyncTv: user.settings.watchlistSyncTv,
email: user.email,
username: savedUser.username,
discordId: savedUser.settings?.discordId,
locale: savedUser.settings?.locale,
region: savedUser.settings?.region,
originalLanguage: savedUser.settings?.originalLanguage,
watchlistSyncMovies: savedUser.settings?.watchlistSyncMovies,
watchlistSyncTv: savedUser.settings?.watchlistSyncTv,
email: savedUser.email,
});
} catch (e) {
next({ status: 500, message: e.message });
Expand Down

0 comments on commit 0bbcfdc

Please sign in to comment.