diff --git a/.changeset/chatty-schools-notice.md b/.changeset/chatty-schools-notice.md new file mode 100644 index 000000000000..f759b1691cc2 --- /dev/null +++ b/.changeset/chatty-schools-notice.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +fix: OAuth login by redirect failing on firefox diff --git a/apps/meteor/app/custom-oauth/client/custom_oauth_client.js b/apps/meteor/app/custom-oauth/client/custom_oauth_client.js index a11277758438..c516f115aede 100644 --- a/apps/meteor/app/custom-oauth/client/custom_oauth_client.js +++ b/apps/meteor/app/custom-oauth/client/custom_oauth_client.js @@ -6,7 +6,6 @@ import { Meteor } from 'meteor/meteor'; import { OAuth } from 'meteor/oauth'; import { ServiceConfiguration } from 'meteor/service-configuration'; -import './swapSessionStorage'; import { isURL } from '../../../lib/utils/isURL'; // Request custom OAuth credentials for the user diff --git a/apps/meteor/app/custom-oauth/client/swapSessionStorage.js b/apps/meteor/app/custom-oauth/client/swapSessionStorage.js deleted file mode 100644 index 83d93310975e..000000000000 --- a/apps/meteor/app/custom-oauth/client/swapSessionStorage.js +++ /dev/null @@ -1,44 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import { OAuth } from 'meteor/oauth'; -import { Reload } from 'meteor/reload'; - -// TODO: This is a nasty workaround and should be removed as soon as possible -// Firefox is losing the sessionStorage data (v >= 79.0) after the redirect - -if (navigator.userAgent.indexOf('Firefox') !== -1) { - const KEY_NAME = 'Swapped_Storage_Workaround'; - - OAuth.saveDataForRedirect = (loginService, credentialToken) => { - Meteor._localStorage.setItem(KEY_NAME, JSON.stringify({ loginService, credentialToken })); - Reload._migrate(null, { immediateMigration: true }); - }; - - OAuth.getDataAfterRedirect = () => { - let migrationData = Meteor._localStorage.getItem(KEY_NAME); - Meteor._localStorage.removeItem(KEY_NAME); - try { - migrationData = JSON.parse(migrationData); - } catch (error) { - migrationData = null; - } - - if (!(migrationData && migrationData.credentialToken)) { - return null; - } - - const { credentialToken } = migrationData; - const key = OAuth._storageTokenPrefix + credentialToken; - let credentialSecret; - try { - credentialSecret = sessionStorage.getItem(key); - sessionStorage.removeItem(key); - } catch (e) { - Meteor._debug('error retrieving credentialSecret', e); - } - return { - loginService: migrationData.loginService, - credentialToken, - credentialSecret, - }; - }; -}