Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions controlplane/src/core/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,26 @@
// Set the sso cookie.
opts.authUtils.createSsoCookie(res, ssoSlug);
}
// Determine the target URL
let targetUrl = opts.webBaseUrl;
if (redirectURL) {
if (redirectURL.startsWith(opts.webBaseUrl)) {
res.redirect(redirectURL);
} else {
res.redirect(opts.webBaseUrl);
try {
const redirectOrigin = new URL(redirectURL).origin;
const webBaseOrigin = new URL(opts.webBaseUrl).origin;
if (redirectOrigin === webBaseOrigin) {
targetUrl = redirectURL;
}
} catch {
// On parse error, keep targetUrl as opts.webBaseUrl
}
} else if (orgs === 0) {
res.redirect(opts.webBaseUrl + '?migrate=true');
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Append onboarding parameter if the user has no orgs
if (orgs === 0) {
const separator = targetUrl.includes('?') ? '&' : '?';
res.redirect(targetUrl + separator + 'onboarding=true');
Comment thread
JivusAyrus marked this conversation as resolved.
Dismissed
} else {
res.redirect(opts.webBaseUrl);
res.redirect(targetUrl);
Comment thread
JivusAyrus marked this conversation as resolved.
}
} catch (err: any) {
if (err instanceof AuthenticationError) {
Expand Down
Loading