132 lines
4.8 KiB
HTML
132 lines
4.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
<meta property="twitter:card" content="summary_large_image" />
|
|
<meta property="og:title" content="Barclays Assistants" />
|
|
<link rel="icon" href="favicon.ico" />
|
|
<link href="style.css" rel="stylesheet" />
|
|
|
|
<!-- auth 1 of 4 -->
|
|
<script src="https://alcdn.msauth.net/browser/2.15.0/js/msal-browser.min.js" crossorigin="anonymous"></script>
|
|
<style>
|
|
#protected-content {
|
|
display: none;
|
|
}
|
|
</style>
|
|
<!-- end auth block -->
|
|
|
|
</head>
|
|
<body id="body">
|
|
|
|
|
|
|
|
<div class="sidebar">
|
|
|
|
<!-- auth 2 of 4 -->
|
|
<div style="text-align: left;">
|
|
<button id="logout-button" onclick="signOut()" style="display:none;">Log Out</button>
|
|
<button id="login-button" onclick="signIn()" style="display:none;">Log In</button>
|
|
</div>
|
|
<!-- end auth block -->
|
|
|
|
<div class="sidebar-content">
|
|
<img src="sparkplug-logo.png" alt="baic" class="logo">
|
|
<div class="sidebar-create-new-btn-container">
|
|
<button onclick="goToCreateNewConversationsPage()">
|
|
<i class="fa-solid fa-plus"></i>
|
|
<span>Create New Conversation</span>
|
|
</button>
|
|
</div>
|
|
<div class="sidebar-subtitle">Conversations</div>
|
|
<div class="conversations-list" id="conversations-list"></div>
|
|
</div>
|
|
<div style="color: rgb(255, 255, 255); text-decoration: none; font-weight: 200; position: absolute; bottom: 0; right: 1px; height: 50px; width: 250px; background-color: black; z-index: 2000;">
|
|
<a href="privacy/" style="color: rgb(255, 255, 255); text-decoration: none; font-weight: 200; position: absolute; bottom: 15px; right: 30px;">View our privacy policy here</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- auth 3 of 4 - assign id = protected-content to div or block to be displayed after successful authentication -->
|
|
<div class="page" id="protected-content">
|
|
<div class="sidebar-toggle-container" onclick="toggleSidebar(event)">
|
|
<button class="sidebar-toggle">
|
|
<div class="sidebar-toggle-bar"></div>
|
|
<div class="sidebar-toggle-bar"></div>
|
|
<div class="sidebar-toggle-bar"></div>
|
|
</button>
|
|
</div>
|
|
<div class="page-content" id="page-content"></div>
|
|
</div>
|
|
</body>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
|
|
<script src="js/variables.js"></script>
|
|
<script src="js/html.js"></script>
|
|
<!-- <script src="js/authorization.js"></script> -->
|
|
|
|
|
|
<!-- auth 4 of 4 NOTE: ensure values for clientID, authority (URL with tenant ID) and redirectUri are correct below -->
|
|
<script>
|
|
const msalConfig = {
|
|
auth: {
|
|
clientId: "9079054c-9620-4757-a256-23413042f1ef",
|
|
authority: "https://login.microsoftonline.com/e519c2e6-bc6d-4fdf-8d9c-923c2f002385",
|
|
redirectUri: "https://ai-sandbox.oliver.solutions/ideas-sparkplug/index.html"
|
|
},
|
|
cache: {
|
|
cacheLocation: "sessionStorage",
|
|
storeAuthStateInCookie: true,
|
|
}
|
|
};
|
|
|
|
const loginRequest = {
|
|
scopes: ["user.read"]
|
|
};
|
|
|
|
const myMSALObj = new msal.PublicClientApplication(msalConfig);
|
|
|
|
signIn();
|
|
|
|
function signIn() {
|
|
myMSALObj.loginPopup(loginRequest)
|
|
.then(loginResponse => {
|
|
console.log("User logged in:", loginResponse.account.username);
|
|
thisUser = loginResponse.account.username;
|
|
sessionStorage.setItem('accessToken', loginResponse.accessToken);
|
|
showProtectedContent(); // Show protected content after successful login
|
|
onAuthenticated(); // Special for this app
|
|
}).catch(error => {
|
|
console.error("Error during login:", error);
|
|
});
|
|
}
|
|
|
|
function signOut() {
|
|
// Clear the session storage and (does not) sign out from Microsoft Identity
|
|
sessionStorage.removeItem('accessToken');
|
|
//myMSALObj.logoutPopup();
|
|
console.log("User logged out.");
|
|
document.getElementById('protected-content').style.display = 'none'; // Hide protected content
|
|
document.getElementById('logout-button').style.display = 'none'; // Hide logout button
|
|
document.getElementById('login-button').style.display = 'flex'; // Show login button
|
|
}
|
|
|
|
|
|
function showProtectedContent() {
|
|
// Verify that the access token exists before showing protected content
|
|
const accessToken = sessionStorage.getItem('accessToken');
|
|
if (accessToken) {
|
|
document.getElementById('protected-content').style.display = 'flex';
|
|
document.getElementById('logout-button').style.display = 'flex'; // Show logout button
|
|
document.getElementById('login-button').style.display = 'none'; // Hide login button
|
|
}
|
|
}
|
|
|
|
// Check if the user is already logged in when the page loads
|
|
window.addEventListener('load', showProtectedContent);
|
|
</script>
|
|
<!-- end auth block -->
|
|
|
|
<script src="js/script.js"></script>
|
|
|
|
|
|
</html>
|