GRN2-107: Add office365 auth (#616)

* add office365 auth

* Delete conflicting file
This commit is contained in:
shawn-higgins1
2019-07-09 13:54:15 -04:00
committed by Jesus Federico
parent 40b05b1626
commit fc18976b6d
22 changed files with 53 additions and 43 deletions

View File

@ -123,7 +123,7 @@
}
}
.customBtn-microsoft_office365 {
.customBtn-office365 {
@extend .customBtn;
background: #f65314;

View File

@ -78,17 +78,23 @@ module SessionsHelper
end
def omniauth_options(env)
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
env["SERVER_PORT"]
user_domain = parse_user_domain(env["SERVER_NAME"])
env['omniauth.strategy'].options[:customer] = user_domain
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url
env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url,
Rails.configuration.launcher_secret)
if env['omniauth.strategy'].options[:name] == "bn-launcher"
gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" +
env["SERVER_PORT"]
user_domain = parse_user_domain(env["SERVER_NAME"])
env['omniauth.strategy'].options[:customer] = user_domain
env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url
env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url
env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url,
Rails.configuration.launcher_secret)
elsif env['omniauth.strategy'].options[:name] == "google"
set_hd(env, ENV['GOOGLE_OAUTH2_HD'])
elsif env['omniauth.strategy'].options[:name] == "office365"
set_hd(env, ENV['OFFICE365_HD'])
end
end
def google_omniauth_hd(env, hd)
def set_hd(env, hd)
hd_opts = hd.split(',')
env['omniauth.strategy'].options[:hd] =
if hd_opts.empty?

View File

@ -70,7 +70,7 @@ class User < ApplicationRecord
# Provider attributes.
def auth_name(auth)
case auth['provider']
when :microsoft_office365
when :office365
auth['info']['display_name']
else
auth['info']['name']
@ -97,7 +97,7 @@ class User < ApplicationRecord
when :twitter
auth['info']['image'].gsub("http", "https").gsub("_normal", "")
else
auth['info']['image'] unless auth['provider'] == :microsoft_office365
auth['info']['image']
end
end
end