Update formAJAX function to log data from the server Add getUserByEmail and checkEmail functions Update profile.ejs to require login Update addSensorData function to emit new sensor data Update api.css with styling changes Update token route to generate and send token email Update authChecker middleware to allow user and token routes
110 lines
4.6 KiB
Plaintext
110 lines
4.6 KiB
Plaintext
<!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 name="description" content="">
|
|
<meta name="author" content="">
|
|
<link rel="shortcut icon" type="images/logo.ico" href="images/logo.ico" />
|
|
<!-- Bootstrap core CSS -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
|
|
|
|
|
<!-- Custom styles for this template -->
|
|
<link rel="stylesheet" href="css/sp.css" />
|
|
|
|
|
|
<!-- jQuery library -->
|
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
|
|
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
|
|
<!-- Bootstrap 5 JavaScript -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
|
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
|
crossorigin="anonymous"></script>
|
|
<!-- Mustache JS -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.1/mustache.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.1/mustache.js"></script>
|
|
<!-- socket.io scriot -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.min.js"></script>
|
|
|
|
<!-- jquery app.js -->
|
|
<script src="js/app.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- javascript function to check if user is auth -->
|
|
<!-- wait for DOC to be ready -->
|
|
|
|
<script>
|
|
//make document ready
|
|
$(document).ready(function () {
|
|
//check if user is logged in
|
|
app.auth.isLoggedIn(function (error, data) {
|
|
if (!error) {
|
|
$("#cl-logout-button").show("fast");
|
|
$("#cl-api-button").show("fast");
|
|
$("#cl-profile-button").show("fast");
|
|
$("#cl-login-button").hide("fast");
|
|
|
|
} else {
|
|
$('#cl-login-button').show('fast');
|
|
|
|
}
|
|
$('body').show('fast')
|
|
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-light top-nav fixed-top">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="/">
|
|
<img src="images/logo.png" alt="logo" />
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
|
|
aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="fas fa-bars"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarResponsive">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/news">News</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/contact">Contact</a>
|
|
</li>
|
|
<!-- profile button -->
|
|
<div class="form-inline mt-2 mt-md-0">
|
|
<a id="cl-api-button" class="btn btn-outline-info btn-sm my-2 my-sm-0" href="/api"
|
|
style="display: none">
|
|
<i class="fas fa-sign-out"></i> API
|
|
</a>
|
|
<a id="cl-profile-button" class="btn btn-outline-info my-2 my-sm-0" href="/profile"
|
|
style="display: none;">
|
|
<i class="fas fa-sign-out"></i>
|
|
Profile
|
|
</a>
|
|
<a id="cl-login-button" class="btn btn-outline-danger my-2 my-sm-0"
|
|
onclick="app.auth.forceLogin()" style="display: none;">
|
|
<i class="fas fa-sign-out"></i>
|
|
Login
|
|
</a>
|
|
<button id="cl-logout-button" class="btn btn-outline-danger my-2 my-sm-0"
|
|
onclick="app.auth.logOut(e => window.location.href='/')" style="display: none;">
|
|
<i class="fas fa-sign-out"></i>
|
|
Logout
|
|
</button>
|
|
</div>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav> |