24 lines
830 B
TypeScript
24 lines
830 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 userData = await googleCallbackService(ctx.query, userHeaderInfo);
|
|
return returnReadResponse(
|
|
ctx.set,
|
|
200,
|
|
"Authenticated successfully!",
|
|
userData
|
|
);
|
|
} catch (error) {
|
|
return mainErrorHandler(ctx.set, error);
|
|
}
|
|
};
|