Skip to content

Commit 483569f

Browse files
authored
Merge pull request #2560 from DMPRoadmap/bug/nil_useridentifier
fix a bug where UserIdentifiers were saved with nil user_id
2 parents 6e37b7d + 6da3a74 commit 483569f

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

app/controllers/registrations_controller.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ def new
3535
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.") % {
3636
application_name: Rails.configuration.branding[:application][:name]
3737
}
38-
# rubocop:enable Metrics/LineLength
39-
scheme = IdentifierScheme.find_by(name: oauth["provider"].downcase)
40-
UserIdentifier.create(identifier_scheme: scheme,
41-
identifier: oauth["uid"],
42-
user: @user)
4338
end
4439
end
4540
end

app/controllers/sessions_controller.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ def create
1919
identifier: session["devise.shibboleth_data"]["uid"],
2020
user: existing_user
2121
}
22-
if UserIdentifier.create(args)
23-
# rubocop:disable Metrics/LineLength
24-
success = _("Your account has been successfully linked to your institutional credentials. You will now be able to sign in with them.")
25-
# rubocop:enable Metrics/LineLength
26-
end
22+
@ui = UserIdentifier.new(args)
2723
end
2824
unless existing_user.get_locale.nil?
2925
session[:locale] = existing_user.get_locale
3026
end
3127
# Method defined at controllers/application_controller.rb
3228
set_gettext_locale
3329
end
34-
super
35-
if success
36-
flash[:notice] = success
30+
31+
super do
32+
if !@ui.nil? && @ui.save
33+
# rubocop:disable Metrics/LineLength
34+
flash[:notice] = _("Your account has been successfully linked to your institutional credentials. You will now be able to sign in with them.")
35+
# rubocop:enable Metrics/LineLength
36+
end
3737
end
3838
end
3939

0 commit comments

Comments
 (0)