diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index fc3447b..db16faf 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -77,6 +77,7 @@ @other_organisations = Org.where(parent_id: nil, is_other: true).pluck(:id) @identifier_schemes = IdentifierScheme.where(active: true).order(:name) @languages = Language.sorted_by_abbreviation + @tab = params[:tab] if params[:skip_personal_details] == "true" do_update_password(current_user, params) else @@ -150,7 +151,7 @@ set_gettext_locale #Method defined at controllers/application_controller.rb set_flash_message :notice, _('Details successfully updated.') sign_in current_user, bypass: true # Sign in the user bypassing validation in case his password changed - redirect_to edit_user_registration_path, notice: _('Details successfully updated.') + redirect_to edit_user_registration_path(@tab), notice: _('Details successfully updated.') else flash[:notice] = message.blank? ? failed_update_error(current_user, _('profile')) : message @@ -174,7 +175,7 @@ set_gettext_locale #Method defined at controllers/application_controller.rb set_flash_message :notice, _('Details successfully updated.') sign_in current_user, bypass: true # Sign in the user bypassing validation in case his password changed - redirect_to edit_user_registration_path, notice: _('Details successfully updated.') + redirect_to edit_user_registration_path(@tab), notice: _('Details successfully updated.') else flash[:notice] = message.blank? ? failed_update_error(current_user, _('profile')) : message diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 05796af..9ad13ce 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -21,7 +21,8 @@ # ------------------------------------------------------------- def handle_omniauth(scheme) user = User.from_omniauth(request.env["omniauth.auth"].nil? ? request.env : request.env["omniauth.auth"]) - + identifier = UserIdentifier.where(identifier: request.env["omniauth.auth"].uid).first + # If the user isn't logged in if current_user.nil? # If the uid didn't have a match in the system send them to register @@ -55,7 +56,11 @@ flash[:notice] = _('Unable to link your account to %{scheme}.') % { scheme: scheme.description } end end - + + if identifier.user.id != current_user.id + flash[:notice] = _("The current #{scheme.description} iD has been already linked to a user with email #{identifier.user.email}") + end + # Redirect to the User Profile page redirect_to edit_user_registration_path end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d3b571d..a99407f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -76,9 +76,9 @@ end end end - + @tab = params[:tab] @user.save - redirect_to edit_user_registration_path(@user), notice: _('Preferences successfully updated.') + redirect_to edit_user_registration_path(tab: @tab), notice: _('Preferences successfully updated.') end end diff --git a/app/views/devise/registrations/_password_details.html.erb b/app/views/devise/registrations/_password_details.html.erb index 2566667..0b0e5eb 100644 --- a/app/views/devise/registrations/_password_details.html.erb +++ b/app/views/devise/registrations/_password_details.html.erb @@ -1,4 +1,4 @@ -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'password'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %>
<%= _('If you would like to change your password please complete the following fields.') %> @@ -14,7 +14,7 @@
- diff --git a/app/views/devise/registrations/_personal_details.html.erb b/app/views/devise/registrations/_personal_details.html.erb index b716279..08a3f91 100644 --- a/app/views/devise/registrations/_personal_details.html.erb +++ b/app/views/devise/registrations/_personal_details.html.erb @@ -1,4 +1,4 @@ -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'personal'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %>

diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 5fa5a66..761abf4 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -5,13 +5,13 @@

@@ -33,5 +33,4 @@
-
- + \ No newline at end of file diff --git a/app/views/users/_notification_preferences.html.erb b/app/views/users/_notification_preferences.html.erb index 04ee630..ce80fa2 100644 --- a/app/views/users/_notification_preferences.html.erb +++ b/app/views/users/_notification_preferences.html.erb @@ -5,7 +5,7 @@
- <%= form_tag(user_update_preferences_path, html: {method: :put, class: "roadmap-form"}) do |f| %> + <%= form_tag( url_for(controller: 'users', action: 'update_preferences', tab: 'preferences', escape: false), html: {method: :put, class: "roadmap-form"}) do |f| %> <%= hidden_field_tag :user_id, @user.id %> diff --git a/lib/assets/javascripts/views/devise/registrations/edit.js b/lib/assets/javascripts/views/devise/registrations/edit.js index ff38153..d5365b8 100644 --- a/lib/assets/javascripts/views/devise/registrations/edit.js +++ b/lib/assets/javascripts/views/devise/registrations/edit.js @@ -20,7 +20,7 @@ }); // Toggle the password field so that its visible/masked - $("#passwords_show").click(function(){ + $("#password_show").click(function(){ var typ = $("#user_current_password").attr('type'); $("#user_current_password").attr('type', (typ === 'password' ? 'text' : 'password')); $("#user_new_password").attr('type', (typ === 'password' ? 'text' : 'password')); @@ -28,7 +28,7 @@ }); // Make sure the show password checkbox is unchecked on load - $("#passwords_show").attr("checked", false); + $("#password_show").attr("checked", false); toggleSubmit(); @@ -49,8 +49,7 @@ var disabled = ($("#user_firstname").val().trim().length <= 0 || $("#user_surname").val().trim().length <= 0 || validateEmail($("#user_email").val()) != '' || - validateEmail($("#user_recovery_email").val()) != '' || - $("#user_new_password").val() != $("#user_password_confirmation").val()); + validateEmail($("#user_recovery_email").val()) != ''); $("#update").attr('aria-disabled', disabled); } });