mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 13:05:08 +09:00
make sure to redirect user on github error
This commit is contained in:
1 parent
5b6ee08a14
commit
34eb450f3e
1 file changed
+12
-1
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user