diff --git a/Gemfile b/Gemfile index e20c06e7..df6935c4 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' +gem 'omniauth-microsoft-office365', '~> 0.0.7' gem 'omniauth-ldap' gem 'omniauth-bn-launcher', '~> 0.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 0401dd50..e1686115 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,6 +160,9 @@ GEM omniauth (~> 1.8.1) pyu-ruby-sasl (~> 0.0.3.3) rubyntlm (~> 0.6.2) + omniauth-microsoft-office365 (0.0.7) + omniauth + omniauth-oauth2 omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) @@ -338,6 +341,7 @@ DEPENDENCIES omniauth-bn-launcher (~> 0.1.0) omniauth-google-oauth2 omniauth-ldap + omniauth-microsoft-office365 (~> 0.0.7) omniauth-twitter pg (~> 0.18) puma (~> 3.0) diff --git a/app/models/user.rb b/app/models/user.rb index 68dcb033..72b7a680 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -60,7 +60,12 @@ class User < ApplicationRecord # Provider attributes. def auth_name(auth) - auth['info']['name'] + case auth['provider'] + when :microsoft_office365 + auth['info']['display_name'] + else + auth['info']['name'] + end end def auth_username(auth) @@ -83,7 +88,7 @@ class User < ApplicationRecord when :twitter auth['info']['image'].gsub("http", "https").gsub("_normal", "") else - auth['info']['image'] + auth['info']['image'] unless auth['provider'] == :microsoft_office365 end end end diff --git a/app/views/shared/modals/_login_modal.html.erb b/app/views/shared/modals/_login_modal.html.erb index eeedd249..6595d54a 100644 --- a/app/views/shared/modals/_login_modal.html.erb +++ b/app/views/shared/modals/_login_modal.html.erb @@ -41,6 +41,12 @@ <% end %> <% end %> + <% if configured_providers.include? :microsoft_office365 %> + <%= link_to omniauth_login_url(:microsoft_office365), class: "btn btn-pill btn-primary btn-block" do %> + <%= t("modal.login.with", provider: "Office365") %> + <% end %> + <% end %> +