Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion static/app/components/modals/sudoModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component, Fragment} from 'react';
import {WithRouterProps} from 'react-router';
import styled from '@emotion/styled';
import trimEnd from 'lodash/trimEnd';

import {logout} from 'sentry/actionCreators/account';
import {ModalRenderProps} from 'sentry/actionCreators/modal';
Expand Down Expand Up @@ -174,7 +175,14 @@ class SudoModal extends Component<Props, State> {
} catch {
// ignore errors
}
window.location.assign(`/auth/login/?next=${encodeURIComponent(location.pathname)}`);
const authLoginPath = `/auth/login/?next=${encodeURIComponent(window.location.href)}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job preserving the querystring in the redirect target 👍

const {superuserUrl} = window.__initialData.links;
if (window.__initialData?.customerDomain && superuserUrl) {
const redirectURL = `${trimEnd(superuserUrl, '/')}${authLoginPath}`;
window.location.assign(redirectURL);
return;
}
window.location.assign(authLoginPath);
};

async getAuthenticators() {
Expand Down
10 changes: 9 additions & 1 deletion static/app/components/superuserAccessForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Component} from 'react';
import styled from '@emotion/styled';
import trimEnd from 'lodash/trimEnd';

import {logout} from 'sentry/actionCreators/account';
import {Client} from 'sentry/api';
Expand Down Expand Up @@ -132,7 +133,14 @@ class SuperuserAccessForm extends Component<Props, State> {
} catch {
// ignore errors
}
window.location.assign('/auth/login/');
const authLoginPath = `/auth/login/?next=${encodeURIComponent(window.location.href)}`;
const {superuserUrl} = window.__initialData.links;
if (window.__initialData?.customerDomain && superuserUrl) {
const redirectURL = `${trimEnd(superuserUrl, '/')}${authLoginPath}`;
window.location.assign(redirectURL);
return;
}
window.location.assign(authLoginPath);
};

async getAuthenticators() {
Expand Down
1 change: 1 addition & 0 deletions static/app/types/system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export interface Config {
organizationUrl: string | undefined;
regionUrl: string | undefined;
sentryUrl: string;
superuserUrl?: string;
};
/**
* This comes from django (django.contrib.messages)
Expand Down