Skip to content

Commit

Permalink
Merge pull request #5893 from dodona-edu/chore/log-events
Browse files Browse the repository at this point in the history
Log usage of legacy identities
  • Loading branch information
jorg-vr authored Oct 25, 2024
2 parents e0a056a + 811f718 commit e9ee308
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/controllers/auth/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def find_identity_by_uid
identity = Identity.joins(:user).find_by(user: { first_name: auth_hash.info.first_name, last_name: auth_hash.info.last_name }, provider: provider, identifier_based_on_email: true) if identity.nil?
return nil if identity.nil?

Event.new(event_type: :other, message: 'Office365 user signed in with legacy identifier').save!

# Update the identifier to the new uid
identity.update(identifier: auth_uid, identifier_based_on_email: false)
elsif provider.class.sym == :smartschool && auth_username.present?
Expand All @@ -249,6 +251,8 @@ def find_identity_by_uid
identity = Identity.joins(:user).find_by(user: { first_name: auth_hash.info.first_name, last_name: auth_hash.info.last_name }, provider: provider, identifier_based_on_username: true) if identity.nil?
return nil if identity.nil?

Event.new(event_type: :other, message: 'Smartschool user signed in with legacy identifier').save!

# Update the identifier to the new uid
identity.update(identifier: auth_uid, identifier_based_on_username: false)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#

class Event < ApplicationRecord
enum :event_type, { rejudge: 0, permission_change: 1, exercise_repository: 2, error: 3 }
enum :event_type, { rejudge: 0, permission_change: 1, exercise_repository: 2, error: 3, other: 4 }
belongs_to :user, optional: true

validates :event_type, presence: true
Expand Down
1 change: 1 addition & 0 deletions config/locales/models/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ en:
permission_change: Change in permission level
exercise_repository: Creation of exercise repository
error: Error
other: Other
export:
statuses:
started: Started
Expand Down
1 change: 1 addition & 0 deletions config/locales/models/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ nl:
permission_change: Verandering in toegangsniveau
exercise_repository: Aanmaak van oefeningenrepository
error: Error
other: Overige
export:
statuses:
started: Begonnen
Expand Down

0 comments on commit e9ee308

Please sign in to comment.