Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github node id #6

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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