♻️ refactor: app token and oAuth endpoint request
These changes include: 1. Replacing the app token with a standard authorization barrier. 2. Changing the response body in the OAuth request by wrapping the endpoint link with a structure instead of placing it in the callback payload data.
This commit is contained in:
@ -1,10 +1,17 @@
|
||||
import { Context } from "elysia";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
import { getOauthProvidersService } from "../services/http/getOauthProviders.service";
|
||||
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
|
||||
|
||||
export const getOauthProvidersController = (ctx: Context) => {
|
||||
try {
|
||||
return getOauthProvidersService();
|
||||
const oauthProviderServices = getOauthProvidersService();
|
||||
return returnReadResponse(
|
||||
ctx.set,
|
||||
200,
|
||||
"Getting all oauth available list",
|
||||
oauthProviderServices
|
||||
);
|
||||
} catch (error) {
|
||||
return mainErrorHandler(ctx.set, error);
|
||||
}
|
||||
|
||||
@ -6,10 +6,7 @@ export const githubRequestController = async (
|
||||
ctx: Context & { query: { callback?: string } }
|
||||
) => {
|
||||
const loginUrl = await githubRequestService(ctx.query.callback);
|
||||
return returnReadResponse(
|
||||
ctx.set,
|
||||
200,
|
||||
"Login URL generated successfully",
|
||||
loginUrl
|
||||
);
|
||||
return returnReadResponse(ctx.set, 200, "Login URL generated successfully", {
|
||||
endpointUrl: loginUrl,
|
||||
});
|
||||
};
|
||||
|
||||
@ -8,12 +8,9 @@ export const googleRequestController = async (
|
||||
) => {
|
||||
try {
|
||||
const loginUrl = await googleRequestService(ctx.query.callback);
|
||||
return returnReadResponse(
|
||||
ctx.set,
|
||||
200,
|
||||
"Google login url created!",
|
||||
loginUrl
|
||||
);
|
||||
return returnReadResponse(ctx.set, 200, "Google login url created!", {
|
||||
endpointUrl: loginUrl,
|
||||
});
|
||||
} catch (error) {
|
||||
return mainErrorHandler(ctx.set, error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user