mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #9943 from AlexSCorey/9115-SSOFix
Fixes SSO Redirect SUMMARY This fixes #9115 by simply checking if there is a redirect url in and then replacing it with the existing url in history, navigating the user to the correct login url. ISSUE TYPE Bugfix Pull Request COMPONENT NAME UI AWX VERSION ADDITIONAL INFORMATION Reviewed-by: Jake McDermott <yo@jakemcdermott.me> Reviewed-by: Alex Corey <Alex.swansboro@gmail.com>
This commit is contained in:
commit
8d20add2d5
@ -42,12 +42,18 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
||||
isLoading: isCustomLoginInfoLoading,
|
||||
error: customLoginInfoError,
|
||||
request: fetchCustomLoginInfo,
|
||||
result: { brandName, logo, loginInfo, socialAuthOptions },
|
||||
result: {
|
||||
brandName,
|
||||
logo,
|
||||
loginInfo,
|
||||
socialAuthOptions,
|
||||
loginRedirectOverride,
|
||||
},
|
||||
} = useRequest(
|
||||
useCallback(async () => {
|
||||
const [
|
||||
{
|
||||
data: { custom_logo, custom_login_info },
|
||||
data: { custom_logo, custom_login_info, login_redirect_override },
|
||||
},
|
||||
{
|
||||
data: { BRAND_NAME },
|
||||
@ -61,11 +67,13 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
||||
const logoSrc = custom_logo
|
||||
? `data:image/jpeg;${custom_logo}`
|
||||
: loginLogoSrc;
|
||||
|
||||
return {
|
||||
brandName: BRAND_NAME,
|
||||
logo: logoSrc,
|
||||
loginInfo: custom_login_info,
|
||||
socialAuthOptions: authData,
|
||||
loginRedirectOverride: login_redirect_override,
|
||||
};
|
||||
}, []),
|
||||
{
|
||||
@ -84,7 +92,6 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
||||
useEffect(() => {
|
||||
fetchCustomLoginInfo();
|
||||
}, [fetchCustomLoginInfo]);
|
||||
|
||||
const {
|
||||
isLoading: isAuthenticating,
|
||||
error: authenticationError,
|
||||
@ -108,7 +115,10 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
||||
if (isCustomLoginInfoLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isAuthenticated(document.cookie) && loginRedirectOverride) {
|
||||
window.location.replace(loginRedirectOverride);
|
||||
return null;
|
||||
}
|
||||
if (isAuthenticated(document.cookie)) {
|
||||
return <Redirect to="/" />;
|
||||
}
|
||||
|
||||
@ -10,6 +10,16 @@ import AWXLogin from './Login';
|
||||
|
||||
jest.mock('../../api');
|
||||
|
||||
RootAPI.readAssetVariables.mockResolvedValue({
|
||||
data: {
|
||||
BRAND_NAME: 'AWX',
|
||||
},
|
||||
});
|
||||
|
||||
AuthAPI.read.mockResolvedValue({
|
||||
data: {},
|
||||
});
|
||||
|
||||
describe('<Login />', () => {
|
||||
async function findChildren(wrapper) {
|
||||
const [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user