mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
feat(web): desktop OAuth deep link redirect
This commit is contained in:
parent
6f9eef6118
commit
a866e6caa1
2 changed files with 18 additions and 0 deletions
|
|
@ -35,6 +35,15 @@ function LoginContent() {
|
|||
localStorage.setItem("surfsense_redirect_path", decodeURIComponent(returnUrl));
|
||||
}
|
||||
|
||||
// Desktop app: persist login source so TokenHandler can redirect to
|
||||
// the surfsense:// deep link after the OAuth round-trip completes.
|
||||
const source = searchParams.get("source");
|
||||
if (source === "desktop") {
|
||||
sessionStorage.setItem("surfsense_login_source", "desktop");
|
||||
} else {
|
||||
sessionStorage.removeItem("surfsense_login_source");
|
||||
}
|
||||
|
||||
// Show registration success message
|
||||
if (registered === "true") {
|
||||
toast.success(t("register_success"), {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ const TokenHandler = ({
|
|||
setRefreshToken(refreshToken);
|
||||
}
|
||||
|
||||
// Desktop app: redirect tokens to the Electron deep link handler
|
||||
const loginSource = sessionStorage.getItem("surfsense_login_source");
|
||||
if (loginSource === "desktop") {
|
||||
sessionStorage.removeItem("surfsense_login_source");
|
||||
const deepLink = `surfsense://auth/callback?token=${token}${refreshToken ? `&refresh_token=${refreshToken}` : ""}`;
|
||||
window.location.href = deepLink;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if there's a saved redirect path from before the auth flow
|
||||
const savedRedirectPath = getAndClearRedirectPath();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue