|
|
@ -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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|