Skip to content

Commit 72db27a

Browse files
committed
remove popup in vanilla and react
1 parent f772f59 commit 72db27a

2 files changed

Lines changed: 6 additions & 42 deletions

File tree

1-Authentication/0-sign-in-vanillajs/App/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h5 id="welcome-div" class="card-header text-center d-none"></h5>
5959
<script type="text/javascript" src="./claimUtils.js"></script>
6060
<!-- <script type="text/javascript" src="./authRedirect.js"></script> -->
6161
<!-- uncomment the above line and comment the line below if you would like to use the redirect flow -->
62-
<script type="text/javascript" src="./authPopup.js"></script>
62+
<script type="text/javascript" src="./authRedirect.js"></script>
6363
</body>
6464

6565
</html>

1-Authentication/1-sign-in-react/SPA/src/components/NavigationBar.jsx

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AuthenticatedTemplate, UnauthenticatedTemplate, useMsal } from '@azure/msal-react';
2-
import { Navbar, Dropdown, DropdownButton } from 'react-bootstrap';
2+
import { Navbar, Button, Dropdown, DropdownButton } from 'react-bootstrap';
33
import { loginRequest } from '../authConfig';
44

55
export const NavigationBar = () => {
@@ -11,33 +11,10 @@ export const NavigationBar = () => {
1111
activeAccount = instance.getActiveAccount();
1212
}
1313

14-
const handleLoginPopup = () => {
15-
/**
16-
* When using popup and silent APIs, we recommend setting the redirectUri to a blank page or a page
17-
* that does not implement MSAL. Keep in mind that all redirect routes must be registered with the application
18-
* For more information, please follow this link: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/login-user.md#redirecturi-considerations
19-
*/
20-
instance
21-
.loginPopup({
22-
...loginRequest,
23-
redirectUri: '/redirect',
24-
})
25-
.catch((error) => console.log(error));
26-
};
27-
2814
const handleLoginRedirect = () => {
2915
instance.loginRedirect(loginRequest).catch((error) => console.log(error));
3016
};
3117

32-
const handleLogoutPopup = () => {
33-
instance
34-
.logoutPopup({
35-
mainWindowRedirectUri: '/', // redirects the top level app after logout
36-
account: instance.getActiveAccount(),
37-
})
38-
.catch((error) => console.log(error));
39-
};
40-
4118
const handleLogoutRedirect = () => {
4219
instance.logoutRedirect().catch((error) => console.log(error));
4320
};
@@ -60,30 +37,17 @@ export const NavigationBar = () => {
6037
drop="start"
6138
title={activeAccount ? activeAccount.name : 'Unknown'}
6239
>
63-
<Dropdown.Item as="button" onClick={handleLogoutPopup}>
64-
Sign out using Popup
65-
</Dropdown.Item>
6640
<Dropdown.Item as="button" onClick={handleLogoutRedirect}>
67-
Sign out using Redirect
41+
Sign out
6842
</Dropdown.Item>
6943
</DropdownButton>
7044
</div>
7145
</AuthenticatedTemplate>
7246
<UnauthenticatedTemplate>
7347
<div className="collapse navbar-collapse justify-content-end">
74-
<DropdownButton
75-
variant="secondary"
76-
className="justify-content-end ml-auto"
77-
title="Sign In"
78-
drop="start"
79-
>
80-
<Dropdown.Item as="button" onClick={handleLoginPopup}>
81-
Sign in using Popup
82-
</Dropdown.Item>
83-
<Dropdown.Item as="button" onClick={handleLoginRedirect}>
84-
Sign in using Redirect
85-
</Dropdown.Item>
86-
</DropdownButton>
48+
<Button onClick={handleLoginRedirect}>
49+
Sign in
50+
</Button>
8751
</div>
8852
</UnauthenticatedTemplate>
8953
</Navbar>

0 commit comments

Comments
 (0)