make sure to redirect user on github error

This commit is contained in:
Sara Vieira committed 2022-06-25 17:02:14 +02:00
1 parent 5b6ee08a14
commit 34eb450f3e
1 file changed
+12 -1
+12 -1
View File
@@ -1,10 +1,21 @@
import { LoaderFunction } from "@remix-run/node";
import { LoaderFunction, redirect } from "@remix-run/node";
import config from "~/config";
import { authenticator } from "~/services/auth.server";
import { ensureUserCookie } from "~/shared/session";
import { LOGIN_ERROR_CODES } from "~/shared/session/useLoginErrors";
export const loader: LoaderFunction = async ({ request }) => {
const { userId } = await ensureUserCookie(request);
const url = new URL(request.url);
const error = url.searchParams.get("error");
const error_description = url.searchParams.get("error_description");
if (error) {
return redirect(
`${config.loginPath}?error=${LOGIN_ERROR_CODES.LOGIN_GITHUB}&message=${
error_description || error
}`
);
}
return authenticator.authenticate("github", request, {
context: {
userId,