mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 12:57:40 -02:30
Fixes SSO Redirect
This commit is contained in:
@@ -42,12 +42,18 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
|||||||
isLoading: isCustomLoginInfoLoading,
|
isLoading: isCustomLoginInfoLoading,
|
||||||
error: customLoginInfoError,
|
error: customLoginInfoError,
|
||||||
request: fetchCustomLoginInfo,
|
request: fetchCustomLoginInfo,
|
||||||
result: { brandName, logo, loginInfo, socialAuthOptions },
|
result: {
|
||||||
|
brandName,
|
||||||
|
logo,
|
||||||
|
loginInfo,
|
||||||
|
socialAuthOptions,
|
||||||
|
loginRedirectOverride,
|
||||||
|
},
|
||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const [
|
const [
|
||||||
{
|
{
|
||||||
data: { custom_logo, custom_login_info },
|
data: { custom_logo, custom_login_info, login_redirect_override },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: { BRAND_NAME },
|
data: { BRAND_NAME },
|
||||||
@@ -61,11 +67,13 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
|||||||
const logoSrc = custom_logo
|
const logoSrc = custom_logo
|
||||||
? `data:image/jpeg;${custom_logo}`
|
? `data:image/jpeg;${custom_logo}`
|
||||||
: loginLogoSrc;
|
: loginLogoSrc;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
brandName: BRAND_NAME,
|
brandName: BRAND_NAME,
|
||||||
logo: logoSrc,
|
logo: logoSrc,
|
||||||
loginInfo: custom_login_info,
|
loginInfo: custom_login_info,
|
||||||
socialAuthOptions: authData,
|
socialAuthOptions: authData,
|
||||||
|
loginRedirectOverride: login_redirect_override,
|
||||||
};
|
};
|
||||||
}, []),
|
}, []),
|
||||||
{
|
{
|
||||||
@@ -84,7 +92,6 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCustomLoginInfo();
|
fetchCustomLoginInfo();
|
||||||
}, [fetchCustomLoginInfo]);
|
}, [fetchCustomLoginInfo]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isLoading: isAuthenticating,
|
isLoading: isAuthenticating,
|
||||||
error: authenticationError,
|
error: authenticationError,
|
||||||
@@ -108,7 +115,10 @@ function AWXLogin({ alt, i18n, isAuthenticated }) {
|
|||||||
if (isCustomLoginInfoLoading) {
|
if (isCustomLoginInfoLoading) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!isAuthenticated(document.cookie) && loginRedirectOverride) {
|
||||||
|
window.location.replace(loginRedirectOverride);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (isAuthenticated(document.cookie)) {
|
if (isAuthenticated(document.cookie)) {
|
||||||
return <Redirect to="/" />;
|
return <Redirect to="/" />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ import AWXLogin from './Login';
|
|||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
|
|
||||||
|
RootAPI.readAssetVariables.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
BRAND_NAME: 'AWX',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
AuthAPI.read.mockResolvedValue({
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
|
||||||
describe('<Login />', () => {
|
describe('<Login />', () => {
|
||||||
async function findChildren(wrapper) {
|
async function findChildren(wrapper) {
|
||||||
const [
|
const [
|
||||||
|
|||||||
Reference in New Issue
Block a user