Merge pull request #344 from trails-cool/stigi/fix-oauth-return
Fix OAuth callback returnTo after settings split
This commit is contained in:
commit
357606ea21
1 changed files with 2 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import { redirect, data } from "react-router";
|
|||
import type { Route } from "./+types/api.sync.connect.$provider";
|
||||
import { getSessionUser } from "~/lib/auth.server";
|
||||
import { getProvider } from "~/lib/sync/registry";
|
||||
import { encodeOAuthState } from "~/lib/sync/pushes.server";
|
||||
|
||||
export async function loader({ params, request }: Route.LoaderArgs) {
|
||||
const user = await getSessionUser(request);
|
||||
|
|
@ -12,7 +13,7 @@ export async function loader({ params, request }: Route.LoaderArgs) {
|
|||
|
||||
const origin = process.env.ORIGIN ?? "http://localhost:3000";
|
||||
const redirectUri = `${origin}/api/sync/callback/${params.provider}`;
|
||||
const state = user.id; // Simple state — could use a CSRF token for production
|
||||
const state = encodeOAuthState({ returnTo: "/settings/connections" });
|
||||
|
||||
return redirect(provider.getAuthUrl(redirectUri, state));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue