Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add query param because of some browsers not sending the referrer
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 9bb2d73 commit c7d1e4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion functions/api/auth/mobile/login.ts
@@ -1,7 +1,7 @@
export async function onRequestGet(_context: RequestContext) {
return new Response(null, {
headers: {
location: "/api/auth/oauth",
location: "/api/auth/oauth?type=mobile",
},
status: 302,
});
Expand Down
6 changes: 6 additions & 0 deletions functions/api/auth/oauth.ts
Expand Up @@ -5,6 +5,12 @@ export async function onRequestGet(context: RequestContext) {
const referer = request.headers.get("referer");

if (referer) returnPath = new URL(referer).pathname;
else {
const { searchParams } = new URL(context.request.url);

if (searchParams.get("type") === "mobile")
returnPath = "/api/auth/mobile/token";
}

const state = crypto.randomUUID().replaceAll("-", "");

Expand Down

0 comments on commit c7d1e4b

Please sign in to comment.