From 811f71892f18c0ecbbf793c0bf9511e594618d06 Mon Sep 17 00:00:00 2001 From: "jorg.vr" Date: Fri, 25 Oct 2024 11:13:17 +0200 Subject: [PATCH] Log usage of legacy providers --- app/controllers/auth/omniauth_callbacks_controller.rb | 4 ++++ app/models/event.rb | 2 +- config/locales/models/en.yml | 1 + config/locales/models/nl.yml | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/auth/omniauth_callbacks_controller.rb b/app/controllers/auth/omniauth_callbacks_controller.rb index 0507db299c..815b0cd499 100644 --- a/app/controllers/auth/omniauth_callbacks_controller.rb +++ b/app/controllers/auth/omniauth_callbacks_controller.rb @@ -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? @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index e06dd8b847..619d21b3a4 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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 diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index c752de4a94..48bce70271 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -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 diff --git a/config/locales/models/nl.yml b/config/locales/models/nl.yml index 900620b19f..ad36111cc1 100644 --- a/config/locales/models/nl.yml +++ b/config/locales/models/nl.yml @@ -176,6 +176,7 @@ nl: permission_change: Verandering in toegangsniveau exercise_repository: Aanmaak van oefeningenrepository error: Error + other: Overige export: statuses: started: Begonnen