Skip to content

Commit

Permalink
fix: hack to fix login
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushik327 committed Apr 1, 2024
1 parent 07a9914 commit 6636f93
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions admin-api-frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { PublicClientApplication, EventType } from '@azure/msal-browser';

import { msalConfig } from './authConfig.js';
import { msalConfig, loginRequest } from './authConfig.js';
import App from './App';

import 'bootstrap/dist/css/bootstrap.min.css';
Expand Down Expand Up @@ -33,8 +33,19 @@ msalInstance.addEventCallback((event) => {

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
<BrowserRouter>
<App instance={msalInstance} />
</BrowserRouter>
);
if (!msalInstance.getActiveAccount()) {
await msalInstance.initialize();
msalInstance.loginPopup(loginRequest).then(response => {
root.render(
<BrowserRouter>
<App instance={msalInstance} />
</BrowserRouter>
);
});
} else {
root.render(
<BrowserRouter>
<App instance={msalInstance} />
</BrowserRouter>
);
}

0 comments on commit 6636f93

Please sign in to comment.