diff --git a/backend/src/strategies/github-token/github-token.service.ts b/backend/src/strategies/github-token/github-token.service.ts index aced6f57..e3b0b0c7 100644 --- a/backend/src/strategies/github-token/github-token.service.ts +++ b/backend/src/strategies/github-token/github-token.service.ts @@ -87,7 +87,7 @@ export class GithubTokenStrategyService extends Strategy { override async getSyncDataForLoginData( loginData: UserLoginData, ): Promise<{ token: string | null; [key: string]: any }> { - return { token: loginData.data["accessToken"] ?? null }; + return { token: loginData.data["token"] ?? null }; } override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object { @@ -123,6 +123,7 @@ export class GithubTokenStrategyService extends Strategy { username: string; displayName: string; email: string; + token: string; } | null> { const graphqlQuery = ` { @@ -155,6 +156,7 @@ export class GithubTokenStrategyService extends Strategy { username: userData.login, displayName: userData.name, email: userData.email, + token }; } @@ -184,15 +186,15 @@ export class GithubTokenStrategyService extends Strategy { override async handleAction(loginData: UserLoginData, name: string, data: Record): Promise { if (name === "update-token") { - const accessToken = data["token"]; - const userLoginData = await this.getUserData(accessToken, await loginData.strategyInstance); + const token = data["token"]; + const userLoginData = await this.getUserData(token, await loginData.strategyInstance); if (userLoginData == null) { throw new HttpException("Token invalid", HttpStatus.BAD_REQUEST); } if (loginData.data["github_id"] !== userLoginData.github_id) { throw new HttpException("Token does not match the user", HttpStatus.BAD_REQUEST); } - loginData.data["accessToken"] = accessToken; + loginData.data["token"] = token; this.loginDataService.save(loginData); } else { throw new HttpException("Unknown action", HttpStatus.BAD_REQUEST); diff --git a/backend/src/strategies/jira-token-cloud/jira-token-cloud.service.ts b/backend/src/strategies/jira-token-cloud/jira-token-cloud.service.ts index 68f3bc2b..bce09693 100644 --- a/backend/src/strategies/jira-token-cloud/jira-token-cloud.service.ts +++ b/backend/src/strategies/jira-token-cloud/jira-token-cloud.service.ts @@ -94,7 +94,7 @@ export class JiraTokenCloudStrategyService extends Strategy { override async getSyncDataForLoginData( loginData: UserLoginData, ): Promise<{ token: string | null; [key: string]: any }> { - return { token: loginData.data["apiToken"] ?? null, type: "PAT" }; + return { token: loginData.data["token"] ?? null, type: "PAT" }; } override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object { @@ -131,6 +131,7 @@ export class JiraTokenCloudStrategyService extends Strategy { username: string; displayName: string; email: string; + token: string; } | null> { const response = await fetch( new URL("/rest/api/2/myself", strategyInstance.instanceConfig["imsTemplatedFieldsFilter"]["root-url"]), @@ -154,6 +155,7 @@ export class JiraTokenCloudStrategyService extends Strategy { username: "", displayName: userData.displayName, email, + token }; } @@ -184,16 +186,16 @@ export class JiraTokenCloudStrategyService extends Strategy { override async handleAction(loginData: UserLoginData, name: string, data: Record): Promise { if (name === "update-token") { - const apiToken = data["token"]; + const token = data["token"]; const email = data["email"] || loginData.data["email"]; - const userLoginData = await this.getUserData(apiToken, email, await loginData.strategyInstance); + const userLoginData = await this.getUserData(token, email, await loginData.strategyInstance); if (userLoginData == null) { throw new HttpException("Token invalid", HttpStatus.BAD_REQUEST); } if (loginData.data["jira_id"] !== userLoginData.jira_id) { throw new HttpException("Token does not match the user", HttpStatus.BAD_REQUEST); } - loginData.data["apiToken"] = apiToken; + loginData.data["token"] = token; loginData.data["email"] = email; this.loginDataService.save(loginData); } else { diff --git a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts index 0ad93ca3..376e393f 100644 --- a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts +++ b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts @@ -83,7 +83,7 @@ export class JiraTokenDatacenterStrategyService extends Strategy { override async getSyncDataForLoginData( loginData: UserLoginData, ): Promise<{ token: string | null; [key: string]: any }> { - return { token: loginData.data["apiToken"] ?? null, type: "PAT" }; + return { token: loginData.data["token"] ?? null, type: "PAT" }; } override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object { @@ -119,6 +119,7 @@ export class JiraTokenDatacenterStrategyService extends Strategy { username: string; displayName: string; email?: string; + token: string; } | null> { const response = await fetch( new URL("/rest/api/2/myself", strategyInstance.instanceConfig["imsTemplatedFieldsFilter"]["root-url"]), @@ -142,6 +143,7 @@ export class JiraTokenDatacenterStrategyService extends Strategy { username: userData.name, displayName: userData.displayName, email: userData.emailAddress, + token }; } @@ -171,15 +173,15 @@ export class JiraTokenDatacenterStrategyService extends Strategy { override async handleAction(loginData: UserLoginData, name: string, data: Record): Promise { if (name === "update-token") { - const apiToken = data["token"]; - const userLoginData = await this.getUserData(apiToken, await loginData.strategyInstance); + const token = data["token"]; + const userLoginData = await this.getUserData(token, await loginData.strategyInstance); if (userLoginData == null) { throw new HttpException("Token invalid", HttpStatus.BAD_REQUEST); } if (loginData.data["jira_id"] !== userLoginData.jira_id) { throw new HttpException("Token does not match the user", HttpStatus.BAD_REQUEST); } - loginData.data["apiToken"] = apiToken; + loginData.data["token"] = token; this.loginDataService.save(loginData); } else { throw new HttpException("Unknown action", HttpStatus.BAD_REQUEST);