Commit fd14406a by AlasdairSwan

ECOM-369 merged and resolved issues with third party auth error messaging

parent 1b1eb781
...@@ -90,13 +90,17 @@ var edx = edx || {}; ...@@ -90,13 +90,17 @@ var edx = edx || {};
*/ */
element: { element: {
hide: function( $el ) { hide: function( $el ) {
$el.addClass('hidden') if ( $el ) {
.attr('aria-hidden', true); $el.addClass('hidden')
.attr('aria-hidden', true);
}
}, },
show: function( $el ) { show: function( $el ) {
$el.removeClass('hidden') if ( $el ) {
.attr('aria-hidden', false); $el.removeClass('hidden')
.attr('aria-hidden', false);
}
} }
}, },
......
...@@ -24,8 +24,6 @@ var edx = edx || {}; ...@@ -24,8 +24,6 @@ var edx = edx || {};
preRender: function( data ) { preRender: function( data ) {
this.providers = data.thirdPartyAuth.providers || []; this.providers = data.thirdPartyAuth.providers || [];
this.currentProvider = data.thirdPartyAuth.currentProvider || ''; this.currentProvider = data.thirdPartyAuth.currentProvider || '';
console.log(data);
}, },
render: function( html ) { render: function( html ) {
...@@ -43,10 +41,11 @@ var edx = edx || {}; ...@@ -43,10 +41,11 @@ var edx = edx || {};
}, },
postRender: function() { postRender: function() {
var $container = $(this.el); this.$container = $(this.el);
this.$form = $container.find('form'); this.$form = this.$container.find('form');
this.$errors = $container.find('.submission-error'); this.$errors = this.$container.find('.submission-error');
this.$authError = this.$container.find('.already-authenticated-msg');
/* If we're already authenticated with a third-party /* If we're already authenticated with a third-party
* provider, try logging in. The easiest way to do this * provider, try logging in. The easiest way to do this
...@@ -87,10 +86,11 @@ var edx = edx || {}; ...@@ -87,10 +86,11 @@ var edx = edx || {};
if ( error.status === 403 && if ( error.status === 403 &&
error.responseText === 'third-party-auth' && error.responseText === 'third-party-auth' &&
this.currentProvider ) { this.currentProvider ) {
this.element.show( this.$alreadyAuthenticatedMsg ); this.element.show( this.$authError );
this.element.hide( this.$errors );
} else { } else {
this.element.hide( this.$alreadyAuthenticatedMsg ); this.element.hide( this.$authError );
// TODO -- display the error this.element.show( this.$errors );
} }
} }
}); });
......
<form id="login"> <form id="login">
<div class="status already-authenticated-msg hidden" aria-hidden="true">
<% if (currentProvider) { %>
<p class="message-copy">You've successfully logged into <%- currentProvider %>, but you need to link your account. Please click "I am a returning user" to create an EdX account.</p>
<% } %>
</div>
<div class="status submission-error hidden" aria-hidden="true"> <div class="status submission-error hidden" aria-hidden="true">
<h4 class="message-title">We couldn't log you in.</h4> <h4 class="message-title">We couldn't log you in.</h4>
<ul class="message-copy"></ul> <ul class="message-copy"></ul>
</div> </div>
<%= fields %> <%= fields %>
<button class="action action-primary action-update js-login">Log in</button> <button class="action action-primary action-update js-login">Log in</button>
</form> </form>
......
<% if (currentProvider) { %> <% if (currentProvider) { %>
<div class="status submission-success" aria-hidden="false"> <div class="status" aria-hidden="false">
<h4 class="message-title">You've successfully signed in with <strong><%- currentProvider %></strong>.</h4> <h4 class="message-title">You've successfully signed in with <strong><%- currentProvider %></strong>.</h4>
<ul class="message-copy"></ul> <p class="message-copy">You've successfully signed in with <strong><%- currentProvider %></strong>. We just need a little more information before you start learning with edX.</p>
</div> </div>
<% } else { <% } else {
_.each( providers, function( provider) { %> _.each( providers, function( provider) { %>
......
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