UserRepository handles updating db settings better.

Moved the plex_userid to settings to expanded with functions for
updating and fetching settings, each with its own helper function
towards the database.
Since we had a linkPlexUserId function and we dont want plex_userid to
be updated from the updatesettings function we moved unlinking to a
separate endpoint and class function.
Also a new controller and endpoints for getting and updating settings.
This commit is contained in:
2019-12-22 13:17:20 +01:00
parent ddb7e7379d
commit f8847c62f2
5 changed files with 264 additions and 71 deletions

View File

@@ -7,10 +7,10 @@ const mustHaveAccountLinkedToPlex = (req, res, next) => {
if (loggedInUser === undefined) {
return res.status(401).send({
success: false,
message: 'You must be logged in.',
message: 'You must have your account linked to a plex account.',
});
} else {
database.get(`SELECT plex_userid FROM user WHERE user_name IS ?`, loggedInUser.username)
database.get(`SELECT plex_userid FROM settings WHERE user_name IS ?`, loggedInUser.username)
.then(row => {
const plex_userid = row.plex_userid;