skip hinted login check added for enterprise SSO
This commit is contained in:
@@ -13,22 +13,16 @@ export default function processLink(link) {
|
|||||||
|
|
||||||
export const getTpaProvider = (tpaHintProvider, primaryProviders, secondaryProviders) => {
|
export const getTpaProvider = (tpaHintProvider, primaryProviders, secondaryProviders) => {
|
||||||
let tpaProvider = null;
|
let tpaProvider = null;
|
||||||
let isSecondaryProvider = false;
|
let skipHintedLogin = false;
|
||||||
primaryProviders.forEach((provider) => {
|
[...primaryProviders, ...secondaryProviders].forEach((provider) => {
|
||||||
if (provider.id === tpaHintProvider) {
|
if (provider.id === tpaHintProvider) {
|
||||||
tpaProvider = provider;
|
tpaProvider = provider;
|
||||||
|
if (provider.skipHintedLogin) {
|
||||||
|
skipHintedLogin = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return { provider: tpaProvider, skipHintedLogin };
|
||||||
if (!tpaProvider) {
|
|
||||||
secondaryProviders.forEach((provider) => {
|
|
||||||
if (provider.id === tpaHintProvider) {
|
|
||||||
tpaProvider = provider;
|
|
||||||
isSecondaryProvider = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return { provider: tpaProvider, isSecondaryProvider };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTpaHint = () => {
|
export const getTpaHint = () => {
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ class LoginPage extends React.Component {
|
|||||||
if (thirdPartyAuthApiStatus === PENDING_STATE) {
|
if (thirdPartyAuthApiStatus === PENDING_STATE) {
|
||||||
return <Skeleton height={36} />;
|
return <Skeleton height={36} />;
|
||||||
}
|
}
|
||||||
const { provider, isSecondaryProvider } = getTpaProvider(this.tpaHint, providers, secondaryProviders);
|
const { provider, skipHintedLogin } = getTpaProvider(this.tpaHint, providers, secondaryProviders);
|
||||||
if (isSecondaryProvider) {
|
if (skipHintedLogin) {
|
||||||
window.location.href = getConfig().LMS_BASE_URL + provider.loginUrl;
|
window.location.href = getConfig().LMS_BASE_URL + provider.loginUrl;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ describe('LoginPage', () => {
|
|||||||
name: 'Test University',
|
name: 'Test University',
|
||||||
loginUrl: '/dummy-auth',
|
loginUrl: '/dummy-auth',
|
||||||
registerUrl: '/dummy_auth',
|
registerUrl: '/dummy_auth',
|
||||||
|
skipHintedLogin: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const appleProvider = {
|
const appleProvider = {
|
||||||
@@ -459,6 +460,28 @@ describe('LoginPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render tpa button for tpa_hint id in secondary provider', () => {
|
it('should render tpa button for tpa_hint id in secondary provider', () => {
|
||||||
|
const expectedMessage = `Sign in using ${secondaryProviders.name}`;
|
||||||
|
store = mockStore({
|
||||||
|
...initialState,
|
||||||
|
commonComponents: {
|
||||||
|
...initialState.commonComponents,
|
||||||
|
thirdPartyAuthContext: {
|
||||||
|
...initialState.commonComponents.thirdPartyAuthContext,
|
||||||
|
secondaryProviders: [secondaryProviders],
|
||||||
|
},
|
||||||
|
thirdPartyAuthApiStatus: COMPLETE_STATE,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
delete window.location;
|
||||||
|
window.location = { href: getConfig().BASE_URL.concat('/login'), search: `?next=/dashboard&tpa_hint=${secondaryProviders.id}` };
|
||||||
|
secondaryProviders.iconImage = null;
|
||||||
|
|
||||||
|
const loginPage = mount(reduxWrapper(<IntlLoginPage {...props} />));
|
||||||
|
expect(loginPage.find(`button#${secondaryProviders.id}`).find('span').text()).toEqual(expectedMessage);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to idp page if skipHinetedLogin is true', () => {
|
||||||
|
secondaryProviders.skipHintedLogin = true;
|
||||||
store = mockStore({
|
store = mockStore({
|
||||||
...initialState,
|
...initialState,
|
||||||
commonComponents: {
|
commonComponents: {
|
||||||
|
|||||||
@@ -626,8 +626,8 @@ class RegistrationPage extends React.Component {
|
|||||||
if (thirdPartyAuthApiStatus === PENDING_STATE) {
|
if (thirdPartyAuthApiStatus === PENDING_STATE) {
|
||||||
return <Skeleton height={36} />;
|
return <Skeleton height={36} />;
|
||||||
}
|
}
|
||||||
const { provider, isSecondaryProvider } = getTpaProvider(this.tpaHint, providers, secondaryProviders);
|
const { provider, skipHintedLogin } = getTpaProvider(this.tpaHint, providers, secondaryProviders);
|
||||||
if (isSecondaryProvider) {
|
if (skipHintedLogin) {
|
||||||
window.location.href = getConfig().LMS_BASE_URL + provider.registerUrl;
|
window.location.href = getConfig().LMS_BASE_URL + provider.registerUrl;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ describe('RegistrationPageTests', () => {
|
|||||||
name: 'Test University',
|
name: 'Test University',
|
||||||
loginUrl: '/dummy-auth',
|
loginUrl: '/dummy-auth',
|
||||||
registerUrl: '/dummy_auth',
|
registerUrl: '/dummy_auth',
|
||||||
|
skipHintedLogin: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const emptyFieldValidation = {
|
const emptyFieldValidation = {
|
||||||
@@ -667,7 +668,7 @@ describe('RegistrationPageTests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
delete window.location;
|
delete window.location;
|
||||||
window.location = { href: getConfig().BASE_URL.concat('/login'), search: `?next=/dashboard&tpa_hint=${appleProvider.id}` };
|
window.location = { href: getConfig().BASE_URL.concat('/register'), search: `?next=/dashboard&tpa_hint=${appleProvider.id}` };
|
||||||
appleProvider.iconImage = null;
|
appleProvider.iconImage = null;
|
||||||
|
|
||||||
const registerPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
const registerPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
||||||
@@ -689,7 +690,7 @@ describe('RegistrationPageTests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
delete window.location;
|
delete window.location;
|
||||||
window.location = { href: getConfig().BASE_URL.concat('/login'), search: '?next=/dashboard&tpa_hint=invalid' };
|
window.location = { href: getConfig().BASE_URL.concat('/register'), search: '?next=/dashboard&tpa_hint=invalid' };
|
||||||
appleProvider.iconImage = null;
|
appleProvider.iconImage = null;
|
||||||
|
|
||||||
const registerPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
const registerPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
||||||
@@ -697,6 +698,28 @@ describe('RegistrationPageTests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render tpa button for tpa_hint id in secondary provider', () => {
|
it('should render tpa button for tpa_hint id in secondary provider', () => {
|
||||||
|
const expectedMessage = `Sign in using ${secondaryProviders.name}`;
|
||||||
|
store = mockStore({
|
||||||
|
...initialState,
|
||||||
|
commonComponents: {
|
||||||
|
...initialState.commonComponents,
|
||||||
|
thirdPartyAuthContext: {
|
||||||
|
...initialState.commonComponents.thirdPartyAuthContext,
|
||||||
|
secondaryProviders: [secondaryProviders],
|
||||||
|
},
|
||||||
|
thirdPartyAuthApiStatus: COMPLETE_STATE,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
delete window.location;
|
||||||
|
window.location = { href: getConfig().BASE_URL.concat('/register'), search: `?next=/dashboard&tpa_hint=${secondaryProviders.id}` };
|
||||||
|
secondaryProviders.iconImage = null;
|
||||||
|
|
||||||
|
const registerPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
||||||
|
expect(registerPage.find(`button#${secondaryProviders.id}`).find('span').text()).toEqual(expectedMessage);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to idp page if skipHinetedLogin is true', () => {
|
||||||
|
secondaryProviders.skipHintedLogin = true;
|
||||||
store = mockStore({
|
store = mockStore({
|
||||||
...initialState,
|
...initialState,
|
||||||
commonComponents: {
|
commonComponents: {
|
||||||
@@ -710,7 +733,7 @@ describe('RegistrationPageTests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
delete window.location;
|
delete window.location;
|
||||||
window.location = { href: getConfig().BASE_URL.concat('/login'), search: `?next=/dashboard&tpa_hint=${secondaryProviders.id}` };
|
window.location = { href: getConfig().BASE_URL.concat('/register'), search: `?next=/dashboard&tpa_hint=${secondaryProviders.id}` };
|
||||||
secondaryProviders.iconImage = null;
|
secondaryProviders.iconImage = null;
|
||||||
|
|
||||||
mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
||||||
|
|||||||
Reference in New Issue
Block a user