feat: bring back Microsoft Controller

I made a booboo, Microsoft concern was actually used in Microsoft::AuthorizationsController, which needed the OAuth client, let's bring it back
This commit is contained in:
Shivam Mishra
2024-06-02 19:34:33 +05:30
parent f906b9a775
commit 4582794ad4
2 changed files with 27 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
module MicrosoftConcern
extend ActiveSupport::Concern
def microsoft_client
app_id = GlobalConfigService.load('AZURE_APP_ID', nil)
app_secret = GlobalConfigService.load('AZURE_APP_SECRET', nil)
::OAuth2::Client.new(app_id, app_secret,
{
site: 'https://login.microsoftonline.com',
authorize_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
token_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
})
end
private
def base_url
ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
end
end
@@ -1,6 +1,12 @@
class Microsoft::CallbacksController < OauthCallbackController
include MicrosoftConcern
private
def oauth_client
microsoft_client
end
def provider_name
'microsoft'
end
@@ -8,16 +14,4 @@ class Microsoft::CallbacksController < OauthCallbackController
def imap_address
'outlook.office365.com'
end
def oauth_client
app_id = GlobalConfigService.load('AZURE_APP_ID', nil)
app_secret = GlobalConfigService.load('AZURE_APP_SECRET', nil)
::OAuth2::Client.new(app_id, app_secret,
{
site: 'https://login.microsoftonline.com',
authorize_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
token_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
})
end
end