diff --git a/app/api/auth/[...nextauth]/authOptions.ts b/app/api/auth/[...nextauth]/authOptions.ts
index a44166b..0969e5f 100644
--- a/app/api/auth/[...nextauth]/authOptions.ts
+++ b/app/api/auth/[...nextauth]/authOptions.ts
@@ -1,8 +1,7 @@
// app/api/auth/[...nextauth]/authOptions.ts
import GitHub from "next-auth/providers/github";
import type { NextAuthOptions } from "next-auth";
-import { checkOnboardingStatus } from "@/services/onboarding/OnboardingService";
-import { getAuthDataByGithubUsername } from "@/services/user/UserService";
+import { checkOnboardingStatus, getAuthDataByGithubUsername } from "@/services/onboarding/DataForgeAuthHelperService";
export const authOptions: NextAuthOptions = {
providers: [
@@ -126,12 +125,10 @@ export const authOptions: NextAuthOptions = {
try {
// Check onboarding status first
- const onboardingStatus = await checkOnboardingStatus(githubUsername);
-
+ const onboardingStatus = await checkOnboardingStatus(githubUsername, true);
if (onboardingStatus.onboarded) {
// User is onboarded - fetch auth credentials
- const authData = await getAuthDataByGithubUsername(githubUsername);
-
+ const authData = await getAuthDataByGithubUsername(githubUsername, true);
newToken.user_id = authData.user_id;
newToken.profile_id = authData.profile_id;
newToken.github_user_name = githubUsername;
@@ -167,12 +164,11 @@ export const authOptions: NextAuthOptions = {
// This runs on every JWT callback invocation (session refresh)
if (token.github_user_name) {
try {
- const onboardingStatus = await checkOnboardingStatus(token.github_user_name);
+ const onboardingStatus = await checkOnboardingStatus(token.github_user_name, true);
if (onboardingStatus.onboarded) {
// User is now onboarded - fetch auth credentials
- const authData = await getAuthDataByGithubUsername(token.github_user_name);
-
+ const authData = await getAuthDataByGithubUsername(token.github_user_name, true);
token.user_id = authData.user_id;
token.profile_id = authData.profile_id;
token.requires_onboarding = false;
diff --git a/app/onboarding/steps/step-career.tsx b/app/onboarding/steps/step-career.tsx
index 74f5a85..49b6c69 100644
--- a/app/onboarding/steps/step-career.tsx
+++ b/app/onboarding/steps/step-career.tsx
@@ -30,7 +30,7 @@ import {
} from "./shared-constants";
import type { StepProps } from "@/types/client/onboarding/onboarding";
import type { StepId } from "@/lib/Zustand/onboarding-store";
-import { checkOnboardingStatus, submitOnboarding } from "@/services/onboarding/OnboardingService";
+import { checkOnboardingStatus, submitOnboarding } from "@/services/onboarding/DataForgeAuthHelperService";
import { OnboardUserRequest } from "@/types/server/dataforge/User/user";
interface CareerStepProps extends StepProps {
diff --git a/components/profile/profile-container.tsx b/components/profile/profile-container.tsx
index 889c2a9..b433a7c 100644
--- a/components/profile/profile-container.tsx
+++ b/components/profile/profile-container.tsx
@@ -50,9 +50,6 @@ export function ProfileContainer() {
return newSet;
});
};
-
- console.log("Session", session);
-
return (
{/* Header */}
diff --git a/services/CoreApiService.ts b/services/CoreApiService.ts
index bebe0d8..e0db0fd 100644
--- a/services/CoreApiService.ts
+++ b/services/CoreApiService.ts
@@ -34,21 +34,21 @@ export type ApiServiceKey = "dataforge" | "gitripper" | "helios" | "archivist" |
export async function apiCall(
service: ApiServiceKey,
path: string | string[],
- init?: RequestInit
+ init?: RequestInit,
+ isFromServer: boolean = false
): Promise {
const pathStr =
typeof path === "string"
? path.replace(/^\/+|\/+$/g, "")
: path.map((s) => String(s).replace(/^\/+|\/+$/g, "")).join("/");
const fullPath = `${service}/${pathStr}`;
- let url = `/api/${fullPath}`;
const method = init?.method ?? "GET";
- const base =
- typeof window === "undefined"
- ? process.env.NEXTAUTH_URL
- : "";
-
- url = `${base}/api/${fullPath}`;
+ let url = "";
+ if (isFromServer == true) {
+ url = `${process.env.NEXT_PUBLIC_DATAFORGE_SERVICE_URL}/${pathStr}`;
+ } else {
+ url = `/api/${fullPath}`;
+ }
const response = await fetch(url, {
...init,
method,
diff --git a/services/onboarding/OnboardingService.ts b/services/onboarding/DataForgeAuthHelperService.ts
similarity index 52%
rename from services/onboarding/OnboardingService.ts
rename to services/onboarding/DataForgeAuthHelperService.ts
index 015ed3f..a8a9a26 100644
--- a/services/onboarding/OnboardingService.ts
+++ b/services/onboarding/DataForgeAuthHelperService.ts
@@ -1,21 +1,26 @@
import { apiCall } from "@/services/CoreApiService";
import type {
CheckOnboardingStatusResponse,
+ GetAuthDataResponse,
OnboardUserRequest,
OnboardUserResponse,
} from "@/types/server/dataforge/User/user";
const ONBOARD_PATH = "Dijkstra/v1/u/onboard";
+const USER_PATH = "Dijkstra/v1/u";
/**
* Check onboarding status for a username
*/
export async function checkOnboardingStatus(
- username: string
+ username: string,
+ isFromServer: boolean = false
): Promise {
return apiCall(
"dataforge",
- `${ONBOARD_PATH}?username=${encodeURIComponent(username)}`
+ `${ONBOARD_PATH}?username=${encodeURIComponent(username)}`,
+ undefined,
+ isFromServer
);
}
@@ -23,10 +28,26 @@ export async function checkOnboardingStatus(
* Submit onboarding data
*/
export async function submitOnboarding(
- data: OnboardUserRequest
+ data: OnboardUserRequest,
+ isFromServer: boolean = false
): Promise {
return apiCall("dataforge", ONBOARD_PATH, {
method: "POST",
body: JSON.stringify(data),
- });
+ }, isFromServer);
}
+
+/**
+ * Get Auth Data by GitHub username
+ */
+export async function getAuthDataByGithubUsername(
+ username: string,
+ isFromServer: boolean = false
+): Promise {
+ return apiCall(
+ "dataforge",
+ `${USER_PATH}/auth/${encodeURIComponent(username)}`,
+ undefined,
+ isFromServer
+ );
+}
\ No newline at end of file
diff --git a/services/user/UserService.ts b/services/user/UserService.ts
index bbca3ac..1e5a016 100644
--- a/services/user/UserService.ts
+++ b/services/user/UserService.ts
@@ -5,9 +5,6 @@ import type {
GetUserBasicResponse,
GetUserSideCardResponse,
} from "@/types/server/dataforge/User/user";
-import type { GetPersonalDetailsResponse } from "@/types/server/dataforge/User/profile";
-import type { PersonalDetailsData } from "@/types/client/profile-section/profile-sections";
-import { transformPersonalDetails } from "@/services/profile/transformers/transformers";
const USER_PATH = "Dijkstra/v1/u";
@@ -34,16 +31,4 @@ export async function getSideCardDetailsByGithubUsername(
"dataforge",
`${USER_PATH}/card/${encodeURIComponent(username)}`
);
-}
-
-/**
- * Get Auth Data by GitHub username
- */
-export async function getAuthDataByGithubUsername(
- username: string
-): Promise {
- return apiCall(
- "dataforge",
- `${USER_PATH}/auth/${encodeURIComponent(username)}`
- );
}
\ No newline at end of file