[❌] Errors
This commit is contained in:
parent
b881a650a6
commit
bad1c5b8d7
|
@ -113,7 +113,6 @@
|
||||||
<input type="password" class="form-control" id="account-confirm-password">
|
<input type="password" class="form-control" id="account-confirm-password">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="login-error"></div>
|
|
||||||
<div id="verification-alert"></div>
|
<div id="verification-alert"></div>
|
||||||
<ul id="login-list">
|
<ul id="login-list">
|
||||||
<li>Loading OAuth2 providers...</li>
|
<li>Loading OAuth2 providers...</li>
|
||||||
|
|
31
src/main.ts
31
src/main.ts
|
@ -87,17 +87,24 @@ async function prepareLoginModal(register: boolean) {
|
||||||
"name": document.querySelector<HTMLInputElement>('#account-username')!.value,
|
"name": document.querySelector<HTMLInputElement>('#account-username')!.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
await pb.collection('users').create(data);
|
await pb.collection('users').create(data).then(async () => {
|
||||||
|
await pb.collection('users').requestVerification(data.email).then(() => $('#verification-alert').html(`
|
||||||
await pb.collection('users').requestVerification(data.email)
|
|
||||||
|
|
||||||
$('#verification-alert').html(`
|
|
||||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
<strong>Verification email sent!</strong> Please check your inbox and click the link to verify your email address.
|
<strong>Verification email sent!</strong> Please check your inbox and click the link to verify your email address.
|
||||||
<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>
|
||||||
|
`))
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
prepareLoginModal(false)
|
||||||
|
$('#verification-alert').html(`
|
||||||
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||||
|
<strong>Error!</strong> ${err}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
document.querySelector<HTMLHeadingElement>('#loginModalLabel')!.innerText = 'Login to your Apexie ID'
|
document.querySelector<HTMLHeadingElement>('#loginModalLabel')!.innerText = 'Login to your Apexie ID'
|
||||||
document.querySelector<HTMLDivElement>('#loginModalFooter')!.innerHTML = `
|
document.querySelector<HTMLDivElement>('#loginModalFooter')!.innerHTML = `
|
||||||
|
@ -110,9 +117,13 @@ async function prepareLoginModal(register: boolean) {
|
||||||
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-register')!.addEventListener('click', () => prepareLoginModal(true))
|
||||||
document.getElementById('account-login')!.addEventListener('click', async () => {
|
document.getElementById('account-login')!.addEventListener('click', async () => {
|
||||||
login_error.innerHTML = ''
|
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(() => {
|
$('#verification-alert').html(`
|
||||||
login_error.innerHTML = 'Failed to authenticate. Please try again.<p>'
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||||
|
<strong>Error!</strong> ${err}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
`)
|
||||||
document.querySelector<HTMLInputElement>('#account-password')!.value = ''
|
document.querySelector<HTMLInputElement>('#account-password')!.value = ''
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -122,10 +133,6 @@ async function prepareLoginModal(register: boolean) {
|
||||||
|
|
||||||
document.getElementById('login_button')!.addEventListener('click', () => prepareLoginModal(false))
|
document.getElementById('login_button')!.addEventListener('click', () => prepareLoginModal(false))
|
||||||
|
|
||||||
let login_error = document.querySelector<HTMLDivElement>('#login-error')!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!gdprConsent) {
|
if (!gdprConsent) {
|
||||||
gdprConsentModal.show()
|
gdprConsentModal.show()
|
||||||
const gdprConsentButton = document.getElementById("gdpr-button")!
|
const gdprConsentButton = document.getElementById("gdpr-button")!
|
||||||
|
|
Loading…
Reference in New Issue