From 0a78b24ef0db7410c21439772b06ceff40693621 Mon Sep 17 00:00:00 2001 From: Alex Dolski Date: Tue, 5 Mar 2024 14:58:36 -0600 Subject: [PATCH] Add from_omniauth_developer() --- app/models/user.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index a71f9712..2e0186e6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -103,7 +103,6 @@ def self.fetch_from_omniauth_saml(auth, email_location:, email_attribute: "emailAddress") auth = auth.deep_symbolize_keys - case email_location when Institution::SAMLEmailLocation::ATTRIBUTE attrs = auth[:extra][:raw_info].attributes.deep_stringify_keys @@ -111,7 +110,6 @@ def self.fetch_from_omniauth_saml(auth, else email = auth[:uid] end - User.find_by_email(email) end @@ -140,10 +138,12 @@ def self.from_autocomplete_string(string) # def self.from_omniauth(auth, institution:) case auth[:provider] - when "saml", "developer" + when "saml" User.from_omniauth_saml(auth, institution: institution) when "identity" User.from_omniauth_local(auth) + when "developer" + User.from_omniauth_developer(auth, institution: institution) else raise ArgumentError, "Unsupported auth provider" end @@ -168,6 +168,19 @@ def self.from_omniauth_local(auth) user end + ## + # @private + # + def self.from_omniauth_developer(auth, institution:) + auth = auth.deep_symbolize_keys + email = auth[:info][:email] + user = User.find_by_email(email) + user ||= User.create!(institution: institution, + email: email, + name: email) + user + end + ## # @private #