🔧 chore: change selected data when create user session

These changes include:
1. Changes to the response structure when logging in with a third-party provider, by wrapping the token in `authToken` instead of directly entering it in the return data section.
2. Adding a type to user session creation by taking only the important elements. This is to prevent data leaks because important data is in jwt.
This commit is contained in:
Rafi Arrafif
2026-01-09 14:10:56 +07:00
parent 0cd253750a
commit 5bcdeae663
3 changed files with 41 additions and 23 deletions

View File

@ -10,13 +10,10 @@ export const githubCallbackController = async (
try {
const userHeaderInfo = getUserHeaderInformation(ctx);
const userData = await githubCallbackService(ctx.query, userHeaderInfo);
return returnWriteResponse(
ctx.set,
200,
"Authenticated successfully!",
userData
);
const authToken = await githubCallbackService(ctx.query, userHeaderInfo);
return returnWriteResponse(ctx.set, 200, "Authenticated successfully!", {
authToken,
});
} catch (error) {
return mainErrorHandler(ctx.set, error);
}

View File

@ -10,13 +10,10 @@ export const googleCallbackController = async (
try {
const userHeaderInfo = getUserHeaderInformation(ctx);
const userData = await googleCallbackService(ctx.query, userHeaderInfo);
return returnReadResponse(
ctx.set,
200,
"Authenticated successfully!",
userData
);
const authToken = await googleCallbackService(ctx.query, userHeaderInfo);
return returnReadResponse(ctx.set, 200, "Authenticated successfully!", {
authToken,
});
} catch (error) {
return mainErrorHandler(ctx.set, error);
}