34 lines
1.2 KiB
JavaScript
Executable file
34 lines
1.2 KiB
JavaScript
Executable file
/*! @azure/msal-react v3.0.17 2025-08-05 */
|
|
'use strict';
|
|
import React__default, { useMemo } from 'react';
|
|
import { getChildrenOrFunction } from '../utils/utilities.js';
|
|
import { useMsal } from '../hooks/useMsal.js';
|
|
import { useIsAuthenticated } from '../hooks/useIsAuthenticated.js';
|
|
import { InteractionStatus } from '@azure/msal-browser';
|
|
|
|
/*
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
/**
|
|
* Renders child components if user is authenticated
|
|
* @param props
|
|
*/
|
|
function AuthenticatedTemplate({ username, homeAccountId, localAccountId, children, }) {
|
|
const context = useMsal();
|
|
const accountIdentifier = useMemo(() => {
|
|
return {
|
|
username,
|
|
homeAccountId,
|
|
localAccountId,
|
|
};
|
|
}, [username, homeAccountId, localAccountId]);
|
|
const isAuthenticated = useIsAuthenticated(accountIdentifier);
|
|
if (isAuthenticated && context.inProgress !== InteractionStatus.Startup) {
|
|
return (React__default.createElement(React__default.Fragment, null, getChildrenOrFunction(children, context)));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export { AuthenticatedTemplate };
|
|
//# sourceMappingURL=AuthenticatedTemplate.js.map
|