feat: add password reset for usermanager (#2688)

* feat: add password reset for usermanager
- add a reset_key to account table
- add ?reset_key= GET arguments to index.html and show reset form if provided
- superuser can generate and copy reset url with key to share
future ideas:
- could add send forgot password email if user fill out email address
* feat: simplify reset key
* test: use reset key
* test: add more tests
* test: reset passwords do not match
* test: `reset_password_auth_threshold_expired`

---------

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
dni ⚡
2024-10-01 10:59:57 +02:00
committed by GitHub
co-authored by Vlad Stan
parent 3a64cf5245
commit a4c000d7dc
12 changed files with 344 additions and 10 deletions
+19
View File
@@ -13,6 +13,7 @@ window.app = Vue.createApp({
authMethod: 'username-password',
usr: '',
username: '',
reset_key: '',
email: '',
password: '',
passwordRepeat: '',
@@ -128,6 +129,18 @@ window.app = Vue.createApp({
LNbits.utils.notifyApiError(e)
}
},
reset: async function () {
try {
await LNbits.api.reset(
this.reset_key,
this.password,
this.passwordRepeat
)
window.location.href = '/wallet'
} catch (e) {
LNbits.utils.notifyApiError(e)
}
},
login: async function () {
try {
await LNbits.api.login(this.username, this.password)
@@ -171,5 +184,11 @@ window.app = Vue.createApp({
if (this.isUserAuthorized) {
window.location.href = '/wallet'
}
this.reset_key = new URLSearchParams(window.location.search).get(
'reset_key'
)
if (this.reset_key) {
this.authAction = 'reset'
}
}
})