fix: remove email requirement for the user, and use the username if no email provided (#900)

* fix: remove email requirement for the user, and use the username if no email provided

* fix: update translations

* fix: remove useless console.log

* test: fix user list test

* fix: disallow Plex users from changing their email
This commit is contained in:
Gauthier
2024-07-29 21:27:31 +02:00
committed by GitHub
parent 422085523e
commit d5f817e734
10 changed files with 85 additions and 45 deletions

View File

@@ -320,7 +320,7 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
// with admin permission
settings.main.mediaServerType = MediaServerType.JELLYFIN;
user = new User({
email: body.email,
email: body.email || account.User.Name,
jellyfinUsername: account.User.Name,
jellyfinUserId: account.User.Id,
jellyfinDeviceId: deviceId,
@@ -328,7 +328,10 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
permissions: Permission.ADMIN,
avatar: account.User.PrimaryImageTag
? `${jellyfinHost}/Users/${account.User.Id}/Images/Primary/?tag=${account.User.PrimaryImageTag}&quality=90`
: gravatarUrl(body.email ?? '', { default: 'mm', size: 200 }),
: gravatarUrl(body.email || account.User.Name, {
default: 'mm',
size: 200,
}),
userType: UserType.JELLYFIN,
});
@@ -371,7 +374,7 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
if (account.User.PrimaryImageTag) {
user.avatar = `${jellyfinHost}/Users/${account.User.Id}/Images/Primary/?tag=${account.User.PrimaryImageTag}&quality=90`;
} else {
user.avatar = gravatarUrl(user.email, {
user.avatar = gravatarUrl(user.email || account.User.Name, {
default: 'mm',
size: 200,
});
@@ -413,10 +416,6 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
}
);
if (!body.email) {
throw new Error('add_email');
}
user = new User({
email: body.email,
jellyfinUsername: account.User.Name,
@@ -426,7 +425,10 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
permissions: settings.main.defaultPermissions,
avatar: account.User.PrimaryImageTag
? `${jellyfinHost}/Users/${account.User.Id}/Images/Primary/?tag=${account.User.PrimaryImageTag}&quality=90`
: gravatarUrl(body.email, { default: 'mm', size: 200 }),
: gravatarUrl(body.email || account.User.Name, {
default: 'mm',
size: 200,
}),
userType: UserType.JELLYFIN,
});
//initialize Jellyfin/Emby users with local login