Skip to content

Commit

Permalink
Merge pull request #2560 from DMPRoadmap/bug/nil_useridentifier
Browse files Browse the repository at this point in the history
fix a bug where UserIdentifiers were saved with nil user_id
  • Loading branch information
briri committed Jun 11, 2020
2 parents 6e37b7d + 6da3a74 commit 483569f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 0 additions & 5 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ def new
flash[:notice] = _("Please make a choice below. After linking your details to a %{application_name} account, you will be able to sign in directly with your institutional credentials.") % {
application_name: Rails.configuration.branding[:application][:name]
}
# rubocop:enable Metrics/LineLength
scheme = IdentifierScheme.find_by(name: oauth["provider"].downcase)
UserIdentifier.create(identifier_scheme: scheme,
identifier: oauth["uid"],
user: @user)
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ def create
identifier: session["devise.shibboleth_data"]["uid"],
user: existing_user
}
if UserIdentifier.create(args)
# rubocop:disable Metrics/LineLength
success = _("Your account has been successfully linked to your institutional credentials. You will now be able to sign in with them.")
# rubocop:enable Metrics/LineLength
end
@ui = UserIdentifier.new(args)
end
unless existing_user.get_locale.nil?
session[:locale] = existing_user.get_locale
end
# Method defined at controllers/application_controller.rb
set_gettext_locale
end
super
if success
flash[:notice] = success

super do
if !@ui.nil? && @ui.save
# rubocop:disable Metrics/LineLength
flash[:notice] = _("Your account has been successfully linked to your institutional credentials. You will now be able to sign in with them.")
# rubocop:enable Metrics/LineLength
end
end
end

Expand Down

0 comments on commit 483569f

Please sign in to comment.