|
|
|
@ -71,6 +71,8 @@ authRoutes.post('/login', async (req, res, next) => {
|
|
|
|
|
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
|
|
|
|
|
// user _assuming_ they have access to the plex server
|
|
|
|
|
const mainUser = await userRepository.findOneOrFail({
|
|
|
|
@ -78,6 +80,7 @@ authRoutes.post('/login', async (req, res, next) => {
|
|
|
|
|
order: { id: 'ASC' },
|
|
|
|
|
});
|
|
|
|
|
const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? '');
|
|
|
|
|
|
|
|
|
|
if (await mainPlexTv.checkUserAccess(account)) {
|
|
|
|
|
user = new User({
|
|
|
|
|
email: account.email,
|
|
|
|
@ -106,9 +109,10 @@ authRoutes.post('/login', async (req, res, next) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set logged in session
|
|
|
|
|
if (req.session && user) {
|
|
|
|
|
if (req.session) {
|
|
|
|
|
req.session.userId = user.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|