Fixed messed up stuff

This commit is contained in:
Anthony 2022-11-24 15:50:59 +00:00
parent bad1c5b8d7
commit 9198b48517
2 changed files with 6 additions and 6 deletions

View File

@ -95,15 +95,15 @@ async function prepareLoginModal(register: boolean) {
</div> </div>
`)) `))
}) })
.catch((err) => { .catch((err) => {
prepareLoginModal(false) prepareLoginModal(false)
$('#verification-alert').html(` $('#verification-alert').html(`
<div class="alert alert-danger alert-dismissible fade show" role="alert"> <div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Error!</strong> ${err} <strong>Error!</strong> ${err}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div> </div>
`) `)
}) })
}) })
} else { } else {
document.querySelector<HTMLHeadingElement>('#loginModalLabel')!.innerText = 'Login to your Apexie ID' document.querySelector<HTMLHeadingElement>('#loginModalLabel')!.innerText = 'Login to your Apexie ID'
@ -112,10 +112,10 @@ async function prepareLoginModal(register: boolean) {
<button type="button" id="account-register" class="btn btn-primary">Register</button> <button type="button" id="account-register" class="btn btn-primary">Register</button>
<button type="submit" id="account-login" class="btn btn-primary">Login</button> <button type="submit" id="account-login" class="btn btn-primary">Login</button>
` `
document.getElementById('account-register')!.addEventListener('click', () => prepareLoginModal(true))
} }
document.querySelector<HTMLDivElement>('#account-username-fill')!.hidden = !register document.querySelector<HTMLDivElement>('#account-username-fill')!.hidden = !register
document.querySelector<HTMLDivElement>('#account-confirm-password-fill')!.hidden = !register document.querySelector<HTMLDivElement>('#account-confirm-password-fill')!.hidden = !register
document.getElementById('account-register')!.addEventListener('click', () => prepareLoginModal(true))
document.getElementById('account-login')!.addEventListener('click', async () => { document.getElementById('account-login')!.addEventListener('click', async () => {
await pb.collection('users').authWithPassword((<HTMLInputElement>document.getElementById('account-email')!).value, (<HTMLInputElement>document.getElementById('account-password')!).value).catch((err) => { await pb.collection('users').authWithPassword((<HTMLInputElement>document.getElementById('account-email')!).value, (<HTMLInputElement>document.getElementById('account-password')!).value).catch((err) => {
$('#verification-alert').html(` $('#verification-alert').html(`

View File

@ -26,7 +26,7 @@ pb.collection('users').authWithOAuth2(
} }
).then(() => { ).then(() => {
// document.getElementById('content').innerText = JSON.stringify(authData, null, 2); // document.getElementById('content').innerText = JSON.stringify(authData, null, 2);
new Location().assign('/') window.location.href = '/'
}).catch((err) => { }).catch((err) => {
document.getElementById('content')!.innerText = "Failed to exchange code.\n" + err document.getElementById('content')!.innerText = "Failed to exchange code.\n" + err
}) })