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| %>