create oauth login

Create authentication with oAuth using a third-party vendor. Currently, only GitHub is available, but more will be added
in the future.
This commit is contained in:
2025-08-05 17:11:36 +07:00
parent 88257d0eee
commit 419b5b0ae4
10 changed files with 132 additions and 4 deletions

View File

@ -0,0 +1,20 @@
import { Context } from "elysia";
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
import { githubCallbackService } from "../services/githubCallback.service";
import { mainErrorHandler } from "../../../helpers/error/handler";
export const githubCallbackController = async (
ctx: Context & { query: { code: string } }
) => {
try {
const userData = await githubCallbackService(ctx.query.code);
return returnWriteResponse(
ctx.set,
200,
"Authenticated successfully!",
userData
);
} catch (error) {
return mainErrorHandler(ctx.set, error);
}
};

View File

@ -0,0 +1,13 @@
import { Context } from "elysia";
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
import { githubRequestService } from "../services/githubRequest.service";
export const githubRequestController = async (ctx: Context) => {
const loginUrl = await githubRequestService();
return returnReadResponse(
ctx.set,
200,
"Login URL generated successfully",
String(loginUrl)
);
};