Initial commit
This commit is contained in:
commit
63ee71a19b
123 files changed
+11268
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { sendFormAsync } from "./shared.js";
|
||||
|
||||
async function redirectIfAlreadySignedIn() {
|
||||
const response = await fetch('/api/v1/auth/me', {
|
||||
method: 'GET',
|
||||
credentials: 'same-origin'
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
window.location.replace('/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
function togglePassword() {
|
||||
const passwordInput = document.getElementById('password');
|
||||
const newInputType = passwordInput.type === 'password' ? 'text' : 'password';
|
||||
passwordInput.type = newInputType;
|
||||
}
|
||||
|
||||
async function submitLoginForm(){
|
||||
const form = document.getElementById('loginForm');
|
||||
await sendFormAsync(form);
|
||||
}
|
||||
|
||||
|
||||
const togglePasswordButton = document.getElementById('togglePassword');
|
||||
togglePasswordButton.addEventListener('click', togglePassword);
|
||||
const loginForm = document.getElementById('loginForm');
|
||||
loginForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
await submitLoginForm();
|
||||
});
|
||||
|
||||
await redirectIfAlreadySignedIn();
|
||||
Reference in new issue
Block a user