feat(component and api): adding emby connect authentication with local account linking
Updated authentication flow to handle local account linking #943
This commit is contained in:
@@ -122,7 +122,7 @@ class JellyfinAPI extends ExternalAPI {
|
||||
},
|
||||
}
|
||||
);
|
||||
this.deviceId = deviceId;
|
||||
this.deviceId = deviceId ? deviceId : undefined;
|
||||
}
|
||||
|
||||
public async login(
|
||||
@@ -187,6 +187,15 @@ class JellyfinAPI extends ExternalAPI {
|
||||
if (e.cause.status === 401) {
|
||||
throw new ApiError(e.cause.status, ApiErrorCode.InvalidCredentials);
|
||||
}
|
||||
|
||||
logger.error(
|
||||
'Something went wrong while authenticating with the Jellyfin server',
|
||||
{
|
||||
label: 'Jellyfin API',
|
||||
error: e.cause.message ?? e.cause.statusText,
|
||||
ip: ClientIP,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -269,14 +269,9 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
|
||||
select: { id: true, jellyfinDeviceId: true },
|
||||
});
|
||||
|
||||
let deviceId = '';
|
||||
if (user) {
|
||||
deviceId = user.jellyfinDeviceId ?? '';
|
||||
} else {
|
||||
deviceId = Buffer.from(`BOT_overseerr_${body.username ?? ''}`).toString(
|
||||
'base64'
|
||||
);
|
||||
}
|
||||
const deviceId =
|
||||
user?.jellyfinDeviceId ??
|
||||
Buffer.from(`BOT_overseerr_${body.username ?? ''}`).toString('base64');
|
||||
|
||||
// First we need to attempt to log the user in to jellyfin
|
||||
const jellyfinserver = new JellyfinAPI(hostname ?? '', undefined, deviceId);
|
||||
@@ -414,7 +409,7 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
|
||||
serverType === ServerType.JELLYFIN ? UserType.JELLYFIN : UserType.EMBY;
|
||||
|
||||
logger.info(
|
||||
`Found matching ${serverType} user; updating user with ${userType}`,
|
||||
`Found matching ${serverType} user; updating user with ${serverType}`,
|
||||
{
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
|
||||
Reference in New Issue
Block a user