Skip to content

Commit

Permalink
chore: make eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienne-deriv committed Nov 27, 2024
1 parent 93cfe40 commit 5fb7037
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 51 deletions.
23 changes: 11 additions & 12 deletions src/javascript/_common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,7 @@ export const requestSingleSignOn = async () => {
const _requestSingleSignOn = async () => {
// if we have previously logged in,
// this cookie will be set by the Callback page (which is exported from @deriv-com/auth-client library) to true when we have successfully logged in from other apps
const currentDomain = window.location.hostname.split('.').slice(-2).join('.');
const isLoggedInCookie = Cookies.get('logged_state', {
expires: 30,
path : '/',
domain : currentDomain,
secure : true,
}) === 'true';
const isLoggedInCookie = Cookies.get('logged_state') === 'true';
const clientAccounts = JSON.parse(localStorage.getItem('client.accounts') || '{}');
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;
const isAuthEnabled = isOAuth2Enabled();
Expand All @@ -175,13 +169,18 @@ export const requestSingleSignOn = async () => {

const isGrowthbookLoaded = Analytics.isGrowthbookLoaded();
if (!isGrowthbookLoaded) {
let retryInterval = 0;
const interval = setInterval(() => {
const isLoaded = Analytics.isGrowthbookLoaded();
// eslint-disable-next-line
console.log('is GB enabled', isLoaded)
if (isLoaded) {
_requestSingleSignOn();
if (retryInterval > 10) {
clearInterval(interval);
} else {
const isLoaded = Analytics.isGrowthbookLoaded();
if (isLoaded) {
_requestSingleSignOn();
clearInterval(interval);
} else {
retryInterval += 1;
}
}
}, 500);
} else {
Expand Down
22 changes: 11 additions & 11 deletions src/javascript/app/base/callback.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable */
const SocketCache = require("../../_common/base/socket_cache");
const CallbackElement = require("../pages/callback/callback");
const SocketCache = require('../../_common/base/socket_cache');
const CallbackElement = require('../pages/callback/callback.jsx');

const CallbackHandler = (() => {
const onLoad = async () => {
CallbackElement.init();
SocketCache.clear();
parent.window.is_logging_in = 1; // this flag is used in base.js to prevent auto-reloading this page
};
const onLoad = async () => {
CallbackElement.init();
SocketCache.clear();

return {
onLoad,
};
parent.window.is_logging_in = 1; // this flag is used in base.js to prevent auto-reloading this page
};

return {
onLoad,
};
})();

module.exports = CallbackHandler;
3 changes: 1 addition & 2 deletions src/javascript/app/base/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const Page = (() => {
Elevio.init();
onDocumentReady();
Crowdin.init();
// only SSO when Analytics is ready
Analytics.init(requestSingleSignOn);
Analytics.init();
};

const onDocumentReady = () => {
Expand Down
51 changes: 25 additions & 26 deletions src/templates/app/callback.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
/* eslint-disable */
import React from "react";
import AntiClickjack from "../_common/includes/anti_clickjack.jsx";
import React from 'react';
import AntiClickjack from '../_common/includes/anti_clickjack.jsx';

const Callback = () => (
<html>
<head>
<AntiClickjack />
{it.js_files.map((js_file, inx) => (
<script
key={inx}
src={js_file.replace(
"{PLACEHOLDER_FOR_LANG}",
it.language.toLowerCase()
)}
/>
))}
<link href="https://style.binary.com/binary.css" rel="stylesheet" />
<meta name="referrer" content="origin" />
</head>
<body>
<div id="content-holder">
<div id="content">
<div id="callback_container" />
</div>
</div>
</body>
</html>
<html>
<head>
<AntiClickjack />
{it.js_files.map((js_file, inx) => (
<script
key={inx}
src={js_file.replace(
'{PLACEHOLDER_FOR_LANG}',
it.language.toLowerCase()
)}
/>
))}
<link href='https://style.binary.com/binary.css' rel='stylesheet' />
<meta name='referrer' content='origin' />
</head>
<body>
<div id='content-holder'>
<div id='content'>
<div id='callback_container' />
</div>
</div>
</body>
</html>
);

export default Callback;

0 comments on commit 5fb7037

Please sign in to comment.