add MS oauth

This commit is contained in:
Alex Turchyn
2023-11-21 00:35:03 +02:00
committed by Pete Matsyburka
parent 83ce401cf2
commit 9f48c6e625
8 changed files with 62 additions and 15 deletions
+13 -4
View File
@@ -4,12 +4,21 @@ module Users
module_function
def from_omniauth(oauth)
user = User.find_by(email: oauth.info.email)
user = User.find_by(email: oauth.info.email.to_s.downcase)
return user if user
User.new(email: oauth.info.email,
first_name: oauth.extra.id_info.given_name,
last_name: oauth.extra.id_info.family_name)
case oauth['provider'].to_s
when 'google_oauth2'
User.new(email: oauth.info.email,
first_name: oauth.extra.id_info.given_name,
last_name: oauth.extra.id_info.family_name)
when 'microsoft_office365'
User.new(email: oauth.info.email,
first_name: oauth.info.first_name,
last_name: oauth.info.last_name)
when 'github'
User.new(email: oauth.info.email, first_name: oauth.info.name)
end
end
end