-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Due to the clients not having a static url, it is not possible to set a specific redirect url in each tracker client. Thus, instead, all trackers have to redirect to suwayomi.org which handles the redirection to the client
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const getStateFromQuery = (query) => { | ||
const urlParams = new URLSearchParams(query); | ||
return JSON.parse(urlParams.get("state")); | ||
}; | ||
|
||
const getRedirectUrlFromQuery = (query = window.location.search) => { | ||
const { redirectUrl } = getStateFromQuery(query); | ||
|
||
if (!redirectUrl) { | ||
throw new Error("No redirectUrl found"); | ||
} | ||
|
||
return `${redirectUrl}${query}`; | ||
}; | ||
|
||
const getRedirectUrlFromHash = () => { | ||
const query = window.location.hash.replace("#", "?"); | ||
return getRedirectUrlFromQuery(query); | ||
}; | ||
|
||
const getRedirectUrl = () => { | ||
try { | ||
return getRedirectUrlFromQuery(); | ||
} catch (e) {} | ||
|
||
return getRedirectUrlFromHash(); | ||
}; | ||
|
||
export const setupTrackerOauthHandler = (router) => { | ||
router.addRoute({ | ||
path: "/tracker-oauth", | ||
beforeEnter() { | ||
console.log("TrackerOauthHandler::handle: location", window.location); | ||
|
||
try { | ||
window.location.href = getRedirectUrl(); | ||
} catch (e) { | ||
console.log("TrackerOauthHandler::handle: redirecting back to the client failed due to", e); | ||
} | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters