From 4917fe11da9d81c0326cc3022d0d1bf745557b80 Mon Sep 17 00:00:00 2001 From: Sammy Date: Sat, 3 Jun 2023 22:06:23 +0200 Subject: [PATCH] fix authentication by not authenticating --- server/jellyfin/handler.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/server/jellyfin/handler.ts b/server/jellyfin/handler.ts index 7c38157..dcf40e1 100644 --- a/server/jellyfin/handler.ts +++ b/server/jellyfin/handler.ts @@ -25,20 +25,22 @@ export class JellyfinHandler { } constructor(_config: Config, _userApi?: UserApi, _systemApi?: SystemApi) { this.config = _config - const userApiConfigurationParams: ConfigurationParameters = { - basePath: this.config.bot.jellyfin_url - } - const systemApiConfigurationParams: ConfigurationParameters = { - basePath: this.config.bot.jellyfin_url - } - this.userApi = _userApi ?? new UserApi(new Configuration(userApiConfigurationParams)) - this.systemApi = _systemApi ?? new SystemApi(new Configuration(systemApiConfigurationParams)) this.token = this.config.bot.jellfin_token this.authHeader = { headers: { "X-MediaBrowser-Token": this.token } } + const userApiConfigurationParams: ConfigurationParameters = { + basePath: this.config.bot.jellyfin_url, + headers: this.authHeader.headers + } + const systemApiConfigurationParams: ConfigurationParameters = { + basePath: this.config.bot.jellyfin_url, + headers: this.authHeader.headers + } + this.userApi = _userApi ?? new UserApi(new Configuration(userApiConfigurationParams)) + this.systemApi = _systemApi ?? new SystemApi(new Configuration(systemApiConfigurationParams)) logger.info(`Initialized Jellyfin handler`, { requestId: 'Init' }) } @@ -51,7 +53,7 @@ export class JellyfinHandler { } private generatePasswordForUser(user: GuildMember): string { - return user.nickname + user.user.discriminator + return user.displayName + user.user.discriminator } public async createUserAccountForDiscordUser(discordUser: GuildMember, guildId?: string, requestId?: string): Promise { @@ -64,7 +66,7 @@ export class JellyfinHandler { } } logger.debug(JSON.stringify(req)) - const createResult = await this.userApi.createUserByName(req, this.authHeader) + const createResult = await this.userApi.createUserByName(req) if (createResult) return createResult else throw new Error('Could not create User in Jellyfin') @@ -79,7 +81,7 @@ export class JellyfinHandler { isDisabled: true }, } - await this.userApi.updateUserPolicy(r, this.authHeader) + await this.userApi.updateUserPolicy(r) logger.info(`Succeeded with disabling user: ${user.name}`) } else { @@ -127,7 +129,7 @@ export class JellyfinHandler { updateUserPolicyRequest: { } } - await this.userApi.updateUserPolicy(r, this.authHeader) + await this.userApi.updateUserPolicy(r) logger.info(`Succeeded with enabling user: ${user.name}`) } else {