📝 docs: complete documentation for auth module
Some checks failed
Integration Tests / integration-tests (pull_request) Failing after 42s
Some checks failed
Integration Tests / integration-tests (pull_request) Failing after 42s
This commit is contained in:
@ -1,14 +1,17 @@
|
||||
import { Context } from "elysia";
|
||||
import { Context, Static } from "elysia";
|
||||
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
||||
import { githubCallbackService } from "../services/http/githubCallback.service";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
import { getUserHeaderInformation } from "../../../helpers/http/userHeader/getUserHeaderInformation";
|
||||
import { githubCallbackSchema } from "../schemas/githubCallback.schema";
|
||||
|
||||
export const githubCallbackController = async (
|
||||
ctx: Context & { query: { code: string; callbackURI: string } }
|
||||
) => {
|
||||
export const githubCallbackController = async (ctx: {
|
||||
set: Context["set"];
|
||||
query: Static<typeof githubCallbackSchema.query>;
|
||||
headers: Static<typeof githubCallbackSchema.headers>;
|
||||
}) => {
|
||||
try {
|
||||
const userHeaderInfo = getUserHeaderInformation(ctx);
|
||||
const userHeaderInfo = getUserHeaderInformation(ctx.headers["x-client-info"]);
|
||||
|
||||
const authToken = await githubCallbackService(ctx.query, userHeaderInfo);
|
||||
return returnWriteResponse(ctx.set, 200, "Authenticated successfully!", {
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
import { Context } from "elysia";
|
||||
import { Context, Static } from "elysia";
|
||||
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
|
||||
import { githubRequestService } from "../services/http/githubRequest.service";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
import { githubRequestSchema } from "../schemas/githubRequest.schema";
|
||||
|
||||
export const githubRequestController = async (
|
||||
ctx: Context & { query: { callback?: string } },
|
||||
) => {
|
||||
export const githubRequestController = async (ctx: {
|
||||
set: Context["set"];
|
||||
query: Static<typeof githubRequestSchema.query>;
|
||||
}) => {
|
||||
try {
|
||||
const loginUrl = await githubRequestService(ctx.query.callback);
|
||||
return returnReadResponse(
|
||||
ctx.set,
|
||||
200,
|
||||
"Login URL generated successfully",
|
||||
{
|
||||
endpointUrl: loginUrl,
|
||||
},
|
||||
);
|
||||
return returnReadResponse(ctx.set, 200, "GitHub login URL created successfully.", {
|
||||
endpointUrl: loginUrl,
|
||||
});
|
||||
} catch (error) {
|
||||
return mainErrorHandler(ctx.set, error);
|
||||
}
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
import { Context } from "elysia";
|
||||
import { Context, Static } 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";
|
||||
import { googleCallbackSchema } from "../schemas/googleCallback.schema";
|
||||
|
||||
export const googleCallbackController = async (
|
||||
ctx: Context & { query: { code: string; state: string; callbackURI: string } },
|
||||
) => {
|
||||
export const googleCallbackController = async (ctx: {
|
||||
set: Context["set"];
|
||||
query: Static<typeof googleCallbackSchema.query>;
|
||||
headers: Static<typeof googleCallbackSchema.headers>;
|
||||
}) => {
|
||||
try {
|
||||
const userHeaderInfo = getUserHeaderInformation(ctx);
|
||||
const userHeaderInfo = getUserHeaderInformation(ctx.headers["x-client-info"]);
|
||||
|
||||
const authToken = await googleCallbackService(ctx.query, userHeaderInfo);
|
||||
return returnReadResponse(ctx.set, 200, "Authenticated successfully!", {
|
||||
return returnReadResponse(ctx.set, 200, "Authentication successful!", {
|
||||
authToken,
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user