Skip to content

Commit

Permalink
corrected paths
Browse files Browse the repository at this point in the history
  • Loading branch information
darkbits018 committed Jan 19, 2024
1 parent a40e78c commit ae4ef56
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 47 deletions.
51 changes: 51 additions & 0 deletions dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<title>Home</title>
</head>

<body>
<div class="cont ms-4">
<h1 id="greet"></h1>
<h2 id="msg"></h2>
<button type="button" class="btn btn-primary" id="signoutbutton">Log Out</button>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<script>
let UserCreds = JSON.parse(sessionStorage.getItem('user-creds'));
let UserInfo = JSON.parse(sessionStorage.getItem('user-info'));

let msgHead = document.getElementById('msg');
let greetHead = document.getElementById('greet');
let signoutButton = document.getElementById('signoutbutton');

greetHead.innerText = `Welcome ${UserInfo.firstname}`;
msgHead.innerText = `logged in with ${UserCreds.email}`;

Signout = () => {
sessionStorage.removeItem('user-creds');
sessionStorage.removeItem('user-info');
window.location.href = "login.html";
}

chkCreds = () => {
if (!sessionStorage.getItem('user-creds')) {
window.location.href = "login.html";
}
}
window.addEventListener('load', chkCreds);
signoutbutton.addEventListener('click', Signout);
</script>
</body>

</html>
61 changes: 17 additions & 44 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,54 +1,27 @@
<!doctype html>
<html lang="en">

<head>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<title>Home</title>
</head>

<body>
<h1 id="greet"></h1>
<h2 id="msg"></h2>

<button type="button" class="btn btn-primary" id="signoutbutton">Log Out</button>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<script>
let UserCreds = JSON.parse(sessionStorage.getItem('user-creds'));
let UserInfo = JSON.parse(sessionStorage.getItem('user-info'));

let msgHead = document.getElementById('msg');
let greetHead = document.getElementById('greet');
let signoutButton = document.getElementById('signoutbutton');
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

greetHead.innerHTML = `Welcome ${UserInfo.firstName}`;
msgHead.innerHTML = `logged in with ${UserInfo.email}`;
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, Click <a href="./register.html">here</a> to begin </h1>

Signout = () => {
sessionStorage.removeItem('user-creds');
sessionStorage.removeItem('user-info');
window.location.href = "login.html";
}
<!-- Optional JavaScript; choose one of the two! -->

chkCreds = () => {
if (!sessionStorage.getItem('user-creds')) {
window.location.href = "login.html";
}
else {
greetHead.innerHTML = `Welcome ${UserInfo.firstName}`;
msgHead.innerHTML = `logged in with ${UserInfo.email}`;
}
}
window.addEventListener('load', chkCreds);
signoutbutton.addEventListener('click', Signout);
</script>
</body>
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>
4 changes: 2 additions & 2 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Login</h2>
</div>
<div class="mx-auto" style="width: fit-content;">
<button type="submit" class="btn btn-primary ">Login</button>
<a href="register.html"><button type="button" class="btn btn-primary">Register</button></a>
<a href="./register.html"><button type="button" class="btn btn-primary">Register</button></a>
</div>
</form>

Expand Down Expand Up @@ -74,7 +74,7 @@ <h2>Login</h2>
lastname: snapshot.val().lastname
}));
sessionStorage.setItem('user-creds', JSON.stringify(credentials.user));
window.location.href = 'index.html';
window.location.href = './dashboard.html';
}
})
} )
Expand Down
2 changes: 1 addition & 1 deletion register.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>Register</h2>
</div>
<div class="mx-auto" style="width: fit-content;">
<button type="submit" class="btn btn-primary ">Register</button>
<a href="login.html"><button type="button" class="btn btn-primary">Login</button></a>
<a href="./login.html"><button type="button" class="btn btn-primary">Login</button></a>
</div>
</form>

Expand Down

0 comments on commit ae4ef56

Please sign in to comment.