[FIX] OAuth login not working on electron app with temp sessions (#22401)

pull/22373/head^2
pierre-lehnen-rc 4 years ago committed by GitHub
parent ee8e2fadd0
commit 94b0d9a43a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      client/startup/index.ts
  2. 21
      client/startup/oauth.ts

@ -9,6 +9,7 @@ import './routes';
import './loginViaQuery';
import './messageTypes';
import './notifications';
import './oauth';
import './readReceipt';
import './renderMessage';
import './renderNotification';

@ -0,0 +1,21 @@
import { Meteor } from 'meteor/meteor';
// @ts-ignore #ToDo: Add definitions for meteor/oauth
import { OAuth } from 'meteor/oauth';
// OAuth._retrieveCredentialSecret is a meteor method modified to also check the global localStorage
// This was necessary because of the "Forget User Session on Window Close" setting.
// The setting changes Meteor._localStorage to use the browser's session storage instead, but that doesn't happen on the Oauth's popup code.
Meteor.startup(() => {
const meteorOAuthRetrieveCredentialSecret = OAuth._retrieveCredentialSecret;
OAuth._retrieveCredentialSecret = (credentialToken: string): string | undefined => {
let secret = meteorOAuthRetrieveCredentialSecret.call(OAuth, credentialToken);
if (!secret) {
const localStorageKey = `${OAuth._storageTokenPrefix}${credentialToken}`;
secret = localStorage.getItem(localStorageKey);
localStorage.removeItem(localStorageKey);
}
return secret;
};
});
Loading…
Cancel
Save