From fd14406aed5df25238cf1ec304686c8faf687e9a Mon Sep 17 00:00:00 2001 From: AlasdairSwan Date: Mon, 27 Oct 2014 14:53:21 -0400 Subject: [PATCH] ECOM-369 merged and resolved issues with third party auth error messaging --- lms/static/js/student_account/views/FormView.js | 12 ++++++++---- lms/static/js/student_account/views/LoginView.js | 16 ++++++++-------- lms/templates/student_account/login.underscore | 7 +++++++ .../student_account/register.underscore | 4 ++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lms/static/js/student_account/views/FormView.js b/lms/static/js/student_account/views/FormView.js index 9aca2099f6..1d00f59a70 100644 --- a/lms/static/js/student_account/views/FormView.js +++ b/lms/static/js/student_account/views/FormView.js @@ -90,13 +90,17 @@ var edx = edx || {}; */ element: { hide: function( $el ) { - $el.addClass('hidden') - .attr('aria-hidden', true); + if ( $el ) { + $el.addClass('hidden') + .attr('aria-hidden', true); + } }, show: function( $el ) { - $el.removeClass('hidden') - .attr('aria-hidden', false); + if ( $el ) { + $el.removeClass('hidden') + .attr('aria-hidden', false); + } } }, diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js index 9642e72c28..132a885378 100644 --- a/lms/static/js/student_account/views/LoginView.js +++ b/lms/static/js/student_account/views/LoginView.js @@ -24,8 +24,6 @@ var edx = edx || {}; preRender: function( data ) { this.providers = data.thirdPartyAuth.providers || []; this.currentProvider = data.thirdPartyAuth.currentProvider || ''; - - console.log(data); }, render: function( html ) { @@ -43,10 +41,11 @@ var edx = edx || {}; }, postRender: function() { - var $container = $(this.el); + this.$container = $(this.el); - this.$form = $container.find('form'); - this.$errors = $container.find('.submission-error'); + this.$form = this.$container.find('form'); + this.$errors = this.$container.find('.submission-error'); + this.$authError = this.$container.find('.already-authenticated-msg'); /* If we're already authenticated with a third-party * provider, try logging in. The easiest way to do this @@ -87,10 +86,11 @@ var edx = edx || {}; if ( error.status === 403 && error.responseText === 'third-party-auth' && this.currentProvider ) { - this.element.show( this.$alreadyAuthenticatedMsg ); + this.element.show( this.$authError ); + this.element.hide( this.$errors ); } else { - this.element.hide( this.$alreadyAuthenticatedMsg ); - // TODO -- display the error + this.element.hide( this.$authError ); + this.element.show( this.$errors ); } } }); diff --git a/lms/templates/student_account/login.underscore b/lms/templates/student_account/login.underscore index d26aa1a15b..2442807959 100644 --- a/lms/templates/student_account/login.underscore +++ b/lms/templates/student_account/login.underscore @@ -1,8 +1,15 @@
+ + + <%= fields %>
diff --git a/lms/templates/student_account/register.underscore b/lms/templates/student_account/register.underscore index 0d1f6e84f4..e98d0f5147 100644 --- a/lms/templates/student_account/register.underscore +++ b/lms/templates/student_account/register.underscore @@ -1,7 +1,7 @@ <% if (currentProvider) { %> -
+

You've successfully signed in with <%- currentProvider %>.

-
    +

    You've successfully signed in with <%- currentProvider %>. We just need a little more information before you start learning with edX.

    <% } else { _.each( providers, function( provider) { %>