fix(api): prevent checking first admin account for plex server access

pull/226/head
sct 4 years ago
parent e7ee85c29b
commit 22006e9dbd

@ -143,8 +143,6 @@ class DiscordAgent
} }
); );
break; break;
default:
color = EmbedColors.DARK_PURPLE;
} }
return { return {

@ -71,6 +71,8 @@ authRoutes.post('/login', async (req, res, next) => {
await userRepository.save(user); await userRepository.save(user);
} }
// Double check that we didn't create the first admin user before running this
if (!user) {
// If we get to this point, the user does not already exist so we need to create the // If we get to this point, the user does not already exist so we need to create the
// user _assuming_ they have access to the plex server // user _assuming_ they have access to the plex server
const mainUser = await userRepository.findOneOrFail({ const mainUser = await userRepository.findOneOrFail({
@ -78,6 +80,7 @@ authRoutes.post('/login', async (req, res, next) => {
order: { id: 'ASC' }, order: { id: 'ASC' },
}); });
const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? ''); const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? '');
if (await mainPlexTv.checkUserAccess(account)) { if (await mainPlexTv.checkUserAccess(account)) {
user = new User({ user = new User({
email: account.email, email: account.email,
@ -106,9 +109,10 @@ authRoutes.post('/login', async (req, res, next) => {
}); });
} }
} }
}
// Set logged in session // Set logged in session
if (req.session && user) { if (req.session) {
req.session.userId = user.id; req.session.userId = user.id;
} }

@ -26,16 +26,12 @@ const SettingsAbout: React.FC = () => {
'/api/v1/settings/about' '/api/v1/settings/about'
); );
if (error) {
return <Error statusCode={500} />;
}
if (!data && !error) { if (!data && !error) {
return <LoadingSpinner />; return <LoadingSpinner />;
} }
if (!data) { if (!data) {
return <LoadingSpinner />; return <Error statusCode={500} />;
} }
return ( return (

Loading…
Cancel
Save