🦖 fix: update payload to match new schema
Some checks failed
Integration Tests / integration-tests (pull_request) Failing after 1m37s
Some checks failed
Integration Tests / integration-tests (pull_request) Failing after 1m37s
This commit is contained in:
@ -16,8 +16,8 @@ interface GithubUserData {
|
|||||||
login: string;
|
login: string;
|
||||||
id: number;
|
id: number;
|
||||||
node_id: string;
|
node_id: string;
|
||||||
avatar_url: string;
|
avatar_url?: string;
|
||||||
gravatar_id: string;
|
gravatar_id?: string;
|
||||||
url: string;
|
url: string;
|
||||||
html_url: string;
|
html_url: string;
|
||||||
followers_url: string;
|
followers_url: string;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { email } from "zod";
|
||||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||||
import { UserHeaderInformation } from "../../../../helpers/http/userHeader/getUserHeaderInformation/types";
|
import { UserHeaderInformation } from "../../../../helpers/http/userHeader/getUserHeaderInformation/types";
|
||||||
import { GithubCallbackUserData } from "../../auth.types";
|
import { GithubCallbackUserData } from "../../auth.types";
|
||||||
@ -6,7 +7,7 @@ import { OAuthUserProvisionService } from "../internal/OAuthUserProvision.servic
|
|||||||
|
|
||||||
export const githubCallbackService = async (
|
export const githubCallbackService = async (
|
||||||
query: { code: string; callbackURI: string },
|
query: { code: string; callbackURI: string },
|
||||||
userHeaderInfo: UserHeaderInformation
|
userHeaderInfo: UserHeaderInformation,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
// Initialize GitHub provider
|
// Initialize GitHub provider
|
||||||
@ -37,21 +38,18 @@ export const githubCallbackService = async (
|
|||||||
// Provision or authenticate the user in the system
|
// Provision or authenticate the user in the system
|
||||||
return await OAuthUserProvisionService(
|
return await OAuthUserProvisionService(
|
||||||
{
|
{
|
||||||
provider: "github",
|
fullname: userPayload.user_data.name || userPayload.user_data.login,
|
||||||
providerId: userPayload.user_data.id.toString(),
|
username: `gh_${userPayload.user_data.id}`,
|
||||||
providerToken: accessToken,
|
email: userPayload.user_email.find((email) => email.primary)?.email || userPayload.user_email[0]?.email,
|
||||||
providerPayload: userPayload,
|
|
||||||
email:
|
|
||||||
userPayload.user_email.find((email) => email.primary === true)
|
|
||||||
?.email || userPayload.user_email[0].email,
|
|
||||||
username: `git_${userPayload.user_data.id}`,
|
|
||||||
name: userPayload.user_data.name ?? userPayload.user_data.login,
|
|
||||||
avatar: userPayload.user_data.avatar_url,
|
avatar: userPayload.user_data.avatar_url,
|
||||||
password: Math.random()
|
bio: userPayload.user_data.bio || undefined,
|
||||||
.toString(36)
|
oauthProvider: {
|
||||||
.slice(2, 16),
|
providerName: "github",
|
||||||
|
sub: userPayload.user_data.id.toString(),
|
||||||
|
token: accessToken,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
userHeaderInfo
|
userHeaderInfo,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ErrorForwarder(error, 500, "Authentication service error");
|
ErrorForwarder(error, 500, "Authentication service error");
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { UserHeaderInformation } from "../../../../helpers/http/userHeader/getUs
|
|||||||
import { createUserSessionService } from "../../../userSession/services/createUserSession.service";
|
import { createUserSessionService } from "../../../userSession/services/createUserSession.service";
|
||||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||||
import { createUserViaOauth } from "../../../user/user.types";
|
import { createUserViaOauth } from "../../../user/user.types";
|
||||||
import { createUserService } from "../../../user/services/internal/createUser.service";
|
|
||||||
import { AppError } from "../../../../helpers/error/instances/app";
|
import { AppError } from "../../../../helpers/error/instances/app";
|
||||||
import { findAuthIdentityByEmailAndProviderRepository } from "../../repositories/READ/findAuthIdentityByEmailAndProvider.repository";
|
import { findAuthIdentityByEmailAndProviderRepository } from "../../repositories/READ/findAuthIdentityByEmailAndProvider.repository";
|
||||||
import { createUserWithOAuthCredentialsRepository } from "../../repositories/WRITE/createUserWithOAuthCredentials.repository";
|
import { createUserWithOAuthCredentialsRepository } from "../../repositories/WRITE/createUserWithOAuthCredentials.repository";
|
||||||
|
|||||||
Reference in New Issue
Block a user