Skip to content

Commit

Permalink
Merge pull request #6 from ccims/feature/github_node_id
Browse files Browse the repository at this point in the history
github node id
  • Loading branch information
chriku authored Oct 20, 2024
2 parents d1e7027 + 6226fb5 commit 9da669b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions backend/src/strategies/github-token/github-token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class GithubTokenStrategyService extends Strategy {
override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object {
return {
github_id: loginData.data["github_id"],
github_node_id: loginData.data["github_node_id"],
username: loginData.data["username"],
displayName: loginData.data["displayName"],
email: loginData.data["email"],
Expand All @@ -102,6 +103,7 @@ export class GithubTokenStrategyService extends Strategy {
override getLoginDataDataForImsUserTemplatedFields(imsUser: object): object | Promise<object> {
return {
github_id: imsUser["github_id"],
github_node_id: imsUser["github_node_id"],
};
}

Expand All @@ -119,7 +121,8 @@ export class GithubTokenStrategyService extends Strategy {
token: string,
strategyInstance: StrategyInstance,
): Promise<{
github_id: string;
github_id: number;
github_node_id: string;
username: string;
displayName: string;
email: string;
Expand All @@ -129,6 +132,7 @@ export class GithubTokenStrategyService extends Strategy {
{
viewer {
id
databaseId
login
name
email
Expand All @@ -152,7 +156,8 @@ export class GithubTokenStrategyService extends Strategy {
const userData = data.data.viewer;

return {
github_id: userData.id,
github_id: userData.databaseId,
github_node_id: userData.id,
username: userData.login,
displayName: userData.name,
email: userData.email,
Expand Down
6 changes: 5 additions & 1 deletion backend/src/strategies/github/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class GithubStrategyService extends StrategyUsingPassport {

override async getSyncDataForLoginData(
loginData: UserLoginData,
): Promise<{ token: string | null; [key: string]: any }> {
): Promise<{ token: string | null;[key: string]: any }> {
const syncLogins = (
await this.activeLoginService.findValidForLoginDataSortedByExpiration(loginData, true)
).filter((login) => !!login.data["accessToken"]);
Expand All @@ -127,6 +127,7 @@ export class GithubStrategyService extends StrategyUsingPassport {
override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object {
return {
github_id: loginData.data["github_id"],
github_node_id: loginData.data["github_node_id"],
username: loginData.data["username"],
displayName: loginData.data["displayName"],
email: loginData.data["email"],
Expand All @@ -136,6 +137,7 @@ export class GithubStrategyService extends StrategyUsingPassport {
override getLoginDataDataForImsUserTemplatedFields(imsUser: object): object | Promise<object> {
return {
github_id: imsUser["github_id"],
github_node_id: imsUser["github_node_id"],
};
}

Expand Down Expand Up @@ -189,11 +191,13 @@ export class GithubStrategyService extends StrategyUsingPassport {
const dataUserLoginData = {
username,
github_id: parseInt(profile.id),
github_node_id: profile.nodeId,
email: profile.emails?.[0]?.value,
displayName: profile.displayName,
};
const loginDataCandidates = await this.loginDataService.findForStrategyWithDataContaining(strategyInstance, {
github_id: parseInt(profile.id),
github_node_id: profile.nodeId,
});
if (loginDataCandidates.length != 1) {
this.loggerGithub.debug("Oauth login didn't find unique login data", loginDataCandidates);
Expand Down

0 comments on commit 9da669b

Please sign in to comment.