mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	Fix issues with Microsoft Provider (#6702)
This commit is contained in:
		| @@ -7,11 +7,12 @@ class Api::V1::Accounts::Microsoft::AuthorizationsController < Api::V1::Accounts | |||||||
|     redirect_url = microsoft_client.auth_code.authorize_url( |     redirect_url = microsoft_client.auth_code.authorize_url( | ||||||
|       { |       { | ||||||
|         redirect_uri: "#{base_url}/microsoft/callback", |         redirect_uri: "#{base_url}/microsoft/callback", | ||||||
|         scope: 'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid', |         scope: 'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid profile', | ||||||
|         prompt: 'consent' |         prompt: 'consent' | ||||||
|       } |       } | ||||||
|     ) |     ) | ||||||
|     if redirect_url |     if redirect_url | ||||||
|  |       email = email.downcase | ||||||
|       ::Redis::Alfred.setex(email, Current.account.id, 5.minutes) |       ::Redis::Alfred.setex(email, Current.account.id, 5.minutes) | ||||||
|       render json: { success: true, url: redirect_url } |       render json: { success: true, url: redirect_url } | ||||||
|     else |     else | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ class Microsoft::CallbacksController < ApplicationController | |||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     inbox = find_or_create_inbox |     inbox = find_or_create_inbox | ||||||
|     ::Redis::Alfred.delete(users_data['email']) |     ::Redis::Alfred.delete(users_data['email'].downcase) | ||||||
|     redirect_to app_microsoft_inbox_agents_url(account_id: account.id, inbox_id: inbox.id) |     redirect_to app_microsoft_inbox_agents_url(account_id: account.id, inbox_id: inbox.id) | ||||||
|   rescue StandardError => e |   rescue StandardError => e | ||||||
|     ChatwootExceptionTracker.new(e).capture_exception |     ChatwootExceptionTracker.new(e).capture_exception | ||||||
| @@ -31,7 +31,7 @@ class Microsoft::CallbacksController < ApplicationController | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def account_id |   def account_id | ||||||
|     ::Redis::Alfred.get(users_data['email']) |     ::Redis::Alfred.get(users_data['email'].downcase) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def account |   def account | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ RSpec.describe 'Microsoft Authorization API', type: :request do | |||||||
|         response_url = microsoft_service.microsoft_client.auth_code.authorize_url( |         response_url = microsoft_service.microsoft_client.auth_code.authorize_url( | ||||||
|           { |           { | ||||||
|             redirect_uri: "#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback", |             redirect_uri: "#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback", | ||||||
|             scope: 'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid', |             scope: 'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid profile', | ||||||
|             prompt: 'consent' |             prompt: 'consent' | ||||||
|           } |           } | ||||||
|         ) |         ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tarang
					Tarang