✨ 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:
20
src/modules/auth/controllers/githubCallback.controller.ts
Normal file
20
src/modules/auth/controllers/githubCallback.controller.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user