<% end %>
<%= render 'devise/shared/links' %>
diff --git a/app/views/icons/_brand_microsoft.html.erb b/app/views/icons/_brand_microsoft.html.erb
new file mode 100644
index 00000000..cbcab3f9
--- /dev/null
+++ b/app/views/icons/_brand_microsoft.html.erb
@@ -0,0 +1,3 @@
+
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index d5ffebfb..f082a7da 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -14,6 +14,7 @@ Devise.otp_allowed_drift = 60.seconds
#
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
+# rubocop:disable Metrics/BlockLength
Devise.setup do |config|
config.warden do |manager|
manager.default_strategies(scope: :user).unshift(:two_factor_authenticatable)
@@ -277,6 +278,12 @@ Devise.setup do |config|
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
config.omniauth :google_oauth2, ENV.fetch('GOOGLE_CLIENT_ID', nil), ENV.fetch('GOOGLE_CLIENT_SECRET', nil), {}
+ config.omniauth :microsoft_office365, ENV.fetch('OFFICE365_CLIENT_ID', nil),
+ ENV.fetch('OFFICE365_CLIENT_SECRET', nil), {}
+
+ if ENV['GITHUB_CLIENT_ID']
+ config.omniauth :github, ENV.fetch('GITHUB_CLIENT_ID', nil), ENV.fetch('GITHUB_CLIENT_SECRET', nil), {}
+ end
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
@@ -316,3 +323,4 @@ Devise.setup do |config|
# changed. Defaults to true, so a user is signed in automatically after changing a password.
# config.sign_in_after_change_password = true
end
+# rubocop:enable Metrics/BlockLength
diff --git a/lib/users.rb b/lib/users.rb
index 775e3e97..0d1bea56 100644
--- a/lib/users.rb
+++ b/lib/users.rb
@@ -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