-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating local login and adding missing pages
- Loading branch information
Showing
4 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<%- include('../partials/header') %> | ||
<section class="page-title light-blue content-block"> | ||
<h1>Reset Local Account Password</h1> | ||
<b style="color: red;">WARNING:</b> This will also delete all existing local accounts and associated projects. This is the intended behaviour as local accounts are only to be used for short term demos. All local accounts are deleted every day at 03:30 UTC.</p> | ||
</section> | ||
<section class="content-block light-blue"> | ||
<div class="reset-password-form-container"> | ||
<form id="resetPasswordForm"> | ||
<div class="form-group"> | ||
<label for="currentPassword">Current Password:</label> | ||
<input type="text" id="currentPassword" readonly> | ||
</div> | ||
<div class="form-group"> | ||
<label for="newPassword">New Password:</label> | ||
<input type="text" name="newPassword" id="newPassword" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="confirmPassword">Confirm New Password:</label> | ||
<input type="text" name="confirmPassword" id="confirmPassword" required> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary">Reset Password</button> | ||
</div> | ||
<div id="error-message" style="color: red;"></div> | ||
<div id="success-message" style="color: green;"></div> | ||
</form> | ||
</div> | ||
</section> | ||
<%- include('../partials/footer') %> | ||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', async function() { | ||
try { | ||
const response = await fetch('/auth/local/password'); | ||
const data = await response.json(); | ||
document.getElementById('currentPassword').value = data.currentPassword; | ||
} catch (error) { | ||
console.error('Error fetching current password:', error); | ||
} | ||
}); | ||
document.getElementById('resetPasswordForm').addEventListener('submit', async function(event) { | ||
event.preventDefault(); | ||
const newPassword = document.getElementById('newPassword').value; | ||
const confirmPassword = document.getElementById('confirmPassword').value; | ||
const errorMessage = document.getElementById('error-message'); | ||
const successMessage = document.getElementById('success-message'); | ||
const currentPasswordField = document.getElementById('currentPassword'); | ||
if (newPassword !== confirmPassword) { | ||
errorMessage.textContent = 'Passwords do not match.'; | ||
return; | ||
} | ||
errorMessage.textContent = ''; // Clear any previous error message | ||
try { | ||
const response = await fetch('/auth/local/password', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ newPassword }) | ||
}); | ||
if (response.ok) { | ||
const result = await response.json(); | ||
successMessage.textContent = result.message || 'Password reset successfully.'; | ||
currentPasswordField.value = newPassword; | ||
document.getElementById('newPassword').value = ''; | ||
document.getElementById('confirmPassword').value = ''; | ||
} else { | ||
const result = await response.json(); | ||
errorMessage.textContent = result.message || 'An error occurred while resetting the password.'; | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
errorMessage.textContent = 'An unexpected error occurred.'; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%- include('../partials/header') %> | ||
<section class="page-title light-blue content-block"> | ||
<h1>Login</h1> | ||
</section> | ||
<section class="content-block light-blue"> | ||
<div class="login-form-container"> | ||
<form action="/auth/local" method="post"> | ||
<div class="form-group"> | ||
<label for="email">Email:</label> | ||
<input type="email" name="email" id="email" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password">Password:</label> | ||
<input type="password" name="password" id="password" required> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary">Login</button> | ||
</div> | ||
</form> | ||
</div> | ||
</section> | ||
<%- include('../partials/footer') %> |