update
1) added html regex 2) added welcome user 3) change forgotpassword and resetpassword to ejs
This commit is contained in:
@ -82,9 +82,6 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Bootstrap core JavaScript -->
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="js/learnmore.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script src="js/api.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<input type="submit" onclick="validateReset()" value="Reset Password" />
|
||||
</form>
|
||||
<br>
|
||||
<a>Dont have an account?</a> <a href="signuplogin.html">Sign Up</a>
|
||||
<a>Dont have an account?</a> <a href="/login">Sign Up</a>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
@ -91,7 +91,6 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<title>EcoSaver - Your Air Quality Index Source</title>
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
|
||||
</head>
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
<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>
|
||||
|
||||
|
||||
<!-- jquery app.js -->
|
||||
<script src="js/app.js"></script>
|
||||
|
||||
@ -83,7 +82,7 @@
|
||||
</li>
|
||||
<!-- profile button -->
|
||||
<div class="form-inline mt-2 mt-md-0">
|
||||
<a id="cl-profile-button" class="btn btn-outline-danger my-2 my-sm-0" href="/profile"
|
||||
<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
|
||||
|
@ -1,6 +1,7 @@
|
||||
<%- include('logintop') %>
|
||||
<script type="text/javascript">
|
||||
app.auth.redirectIfLoggedIn();
|
||||
// Require login to see this page.
|
||||
//app.auth.redirectIfLoggedIn();
|
||||
</script>
|
||||
|
||||
<body>
|
||||
@ -11,14 +12,18 @@
|
||||
<!-- localhost/api/v0/user/register -->
|
||||
<!-- evalAjax Fires when status 200 is returned -->
|
||||
<form action="auth/register" onsubmit="formAJAX(this)" evalAJAX="app.auth.logInRedirect();">
|
||||
<input type="text" name="firstname" placeholder="First Name" required />
|
||||
<input type="text" name="lastname" placeholder="Last Name" required />
|
||||
<input type="text" name="username" placeholder="Username" required />
|
||||
<input type="text" name="email" placeholder="Email" required />
|
||||
<input type="text" name="address" placeholder="Address" required />
|
||||
<input type="text" name="phone" placeholder="Phone Number" required />
|
||||
<input type="password" name="password" placeholder="Password" required />
|
||||
<input type="password" name="confirmPassword" placeholder="Confirm Password" required />
|
||||
<input type="text" name="firstname" placeholder="First Name" required pattern="^[a-zA-Z\s]+$" />
|
||||
<input type="text" name="lastname" placeholder="Last Name" required pattern="^[a-zA-Z\s]+$" />
|
||||
<input type="text" name="username" placeholder="Username" required pattern="^\w+$" />
|
||||
<input type="email" name="email" placeholder="Email" required
|
||||
pattern="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
|
||||
<input type="text" name="address" placeholder="Address" required
|
||||
pattern="^(\d{1,3}.)?.+\s(\d{6})$" />
|
||||
<input type="text" name="phone" placeholder="Phone Number" required
|
||||
pattern="^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,8}$" />
|
||||
<input type="password" id="password" name="password" placeholder="Password" required />
|
||||
<input type="password" id="confirmPassword" name="confirmPassword" placeholder="Confirm Password"
|
||||
required />
|
||||
<input type="submit" value="Signup" />
|
||||
</form>
|
||||
</div>
|
||||
@ -29,15 +34,39 @@
|
||||
<!-- evalAjax Fires when status 200 is returned -->
|
||||
<form action="auth/login" onsubmit="formAJAX(this)" evalAJAX="app.auth.homeRedirect();
|
||||
app.auth.setToken(data.token);">
|
||||
|
||||
<input type="text" name="userInfo" placeholder="Email address | Username" required />
|
||||
<input type="text" name="username" placeholder="Email address | Username" required
|
||||
pattern="^\w+$" />
|
||||
<input type="password" name="password" placeholder="Password" required />
|
||||
<a href="/resetPassword">Forgot password?</a>
|
||||
<a href="/forgotpassword">Forgot password?</a>
|
||||
<input type="submit" value="Login" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
//both password fields must match
|
||||
var password = document.getElementById("password");
|
||||
var confirm_password = document.getElementById("confirmPassword");
|
||||
|
||||
function validatePassword() {
|
||||
var passwordValue = password.value;
|
||||
|
||||
// Strong password regex pattern
|
||||
var strongPasswordPattern = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/;
|
||||
|
||||
if (passwordValue != confirm_password.value) {
|
||||
confirm_password.setCustomValidity("Passwords Don't Match");
|
||||
} else if (!strongPasswordPattern.test(passwordValue)) {
|
||||
confirm_password.setCustomValidity("Password must be at least 8 characters long and include at least one letter, one number, and one special character.");
|
||||
} else {
|
||||
confirm_password.setCustomValidity('');
|
||||
}
|
||||
}
|
||||
|
||||
password.onchange = validatePassword;
|
||||
confirm_password.onkeyup = validatePassword;
|
||||
|
||||
|
||||
|
||||
const wrapper = document.querySelector(".wrapper"),
|
||||
signupHeader = document.querySelector(".signup header"),
|
||||
loginHeader = document.querySelector(".login header");
|
||||
|
@ -33,10 +33,8 @@
|
||||
<!-- Mustache JS -->
|
||||
<script src="https://sso.theta42.com/static/js/mustache.min.js"></script>
|
||||
<!-- jQuery library -->
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.7.1.min.js"
|
||||
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 5 JavaScript -->
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||
@ -63,6 +61,7 @@
|
||||
//check if user is logged in
|
||||
app.auth.isLoggedIn(function (error, data) {
|
||||
if (data) {
|
||||
app.auth.showUser();
|
||||
$("#cl-logout-button").show("fast");
|
||||
$("#cl-profile-button").show("fast");
|
||||
$("#cl-login-button").hide("fast");
|
||||
@ -71,7 +70,8 @@
|
||||
}
|
||||
$("body").show("fast");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<body>
|
||||
@ -94,7 +94,7 @@
|
||||
<div class="collapse navbar-collapse" id="navbarResponsive">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li jq-repeat="getUsername" class="nav-item">
|
||||
{{ username }}
|
||||
<a class="nav-link"> Welcome {{ user.username }} </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
|
Reference in New Issue
Block a user