Commit 05001bbb by Braden MacDonald Committed by David Baumgold

Fix hinted login view to be compatible with secondary providers.

parent f1829eb1
...@@ -28,15 +28,23 @@ define([ ...@@ -28,15 +28,23 @@ define([
loginUrl: '/auth/login/facebook/?auth_entry=account_login', loginUrl: '/auth/login/facebook/?auth_entry=account_login',
registerUrl: '/auth/login/facebook/?auth_entry=account_register' registerUrl: '/auth/login/facebook/?auth_entry=account_register'
} }
],
secondaryProviders: [
{
id: 'saml-harvard',
name: 'Harvard',
iconClass: 'fa-university',
loginUrl: '/auth/login/tpa-saml/?auth_entry=account_login&idp=harvard',
registerUrl: '/auth/login/tpa-saml/?auth_entry=account_register&idp=harvard'
}
] ]
}, };
HINTED_PROVIDER = "oa2-google-oauth2";
var createHintedLoginView = function(test) { var createHintedLoginView = function(hintedProvider) {
// Initialize the login view // Initialize the login view
view = new HintedLoginView({ view = new HintedLoginView({
thirdPartyAuth: THIRD_PARTY_AUTH, thirdPartyAuth: THIRD_PARTY_AUTH,
hintedProvider: HINTED_PROVIDER, hintedProvider: hintedProvider,
platformName: PLATFORM_NAME platformName: PLATFORM_NAME
}); });
...@@ -52,15 +60,23 @@ define([ ...@@ -52,15 +60,23 @@ define([
}); });
it('displays a choice as two buttons', function() { it('displays a choice as two buttons', function() {
createHintedLoginView(this); createHintedLoginView("oa2-google-oauth2");
expect($('.proceed-button.button-oa2-google-oauth2')).toBeVisible(); expect($('.proceed-button.button-oa2-google-oauth2')).toBeVisible();
expect($('.form-toggle')).toBeVisible(); expect($('.form-toggle')).toBeVisible();
expect($('.proceed-button.button-oa2-facebook')).not.toBeVisible(); expect($('.proceed-button.button-oa2-facebook')).not.toBeVisible();
}); });
it('works with secondary providers as well', function() {
createHintedLoginView("saml-harvard");
expect($('.proceed-button.button-saml-harvard')).toBeVisible();
expect($('.form-toggle')).toBeVisible();
expect($('.proceed-button.button-oa2-google-oauth2')).not.toBeVisible();
});
it('redirects the user to the hinted provider if the user clicks the proceed button', function() { it('redirects the user to the hinted provider if the user clicks the proceed button', function() {
createHintedLoginView(this); createHintedLoginView("oa2-google-oauth2");
// Click the "Yes, proceed" button // Click the "Yes, proceed" button
$('.proceed-button').click(); $('.proceed-button').click();
......
...@@ -19,18 +19,14 @@ var edx = edx || {}; ...@@ -19,18 +19,14 @@ var edx = edx || {};
initialize: function( data ) { initialize: function( data ) {
this.tpl = $(this.tpl).html(); this.tpl = $(this.tpl).html();
this.providers = data.thirdPartyAuth.providers || []; this.hintedProvider = (
this.hintedProvider = _.findWhere(this.providers, {id: data.hintedProvider}) _.findWhere(data.thirdPartyAuth.providers, {id: data.hintedProvider}) ||
this.platformName = data.platformName; _.findWhere(data.thirdPartyAuth.secondaryProviders, {id: data.hintedProvider})
);
}, },
render: function() { render: function() {
$(this.el).html( _.template( this.tpl, { $(this.el).html( _.template( this.tpl, {
// We pass the context object to the template so that
// we can perform variable interpolation using sprintf
providers: this.providers,
platformName: this.platformName,
hintedProvider: this.hintedProvider hintedProvider: this.hintedProvider
})); }));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment