Files
AnimeTV-Backend/src/modules/auth/controllers/googleCallback.controller.ts
Rafi Arrafif 5bcdeae663 🔧 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.
2026-01-09 14:10:56 +07:00

21 lines
817 B
TypeScript

import { Context } from "elysia";
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
import { mainErrorHandler } from "../../../helpers/error/handler";
import { googleCallbackService } from "../services/http/googleCallback.service";
import { getUserHeaderInformation } from "../../../helpers/http/userHeader/getUserHeaderInformation";
export const googleCallbackController = async (
ctx: Context & { query: { code: string; state: string; callbackURI: string } }
) => {
try {
const userHeaderInfo = getUserHeaderInformation(ctx);
const authToken = await googleCallbackService(ctx.query, userHeaderInfo);
return returnReadResponse(ctx.set, 200, "Authenticated successfully!", {
authToken,
});
} catch (error) {
return mainErrorHandler(ctx.set, error);
}
};