feat(webui): add user account delete
All checks were successful
main / main (push) Successful in 1m46s
main / deploy (push) Has been skipped
main / publish (push) Has been skipped

Closes #19
This commit is contained in:
Julien Dessaux 2025-05-05 00:34:08 +02:00
parent 373f567773
commit 8d75b75af7
Signed by: adyxax
GPG key ID: F92E51B86E07177E
6 changed files with 57 additions and 20 deletions

View file

@ -21,6 +21,7 @@ type Account struct {
LastLogin time.Time `json:"last_login"`
Settings *Settings `json:"settings"`
PasswordReset *uuid.UUID `json:"password_reset"`
Deleted bool `json:"deleted"`
}
func (account *Account) CheckPassword(password string) bool {
@ -28,6 +29,13 @@ func (account *Account) CheckPassword(password string) bool {
return subtle.ConstantTimeCompare(hash, account.PasswordHash) == 1
}
func (account *Account) MarkForDeletion() {
account.Salt = nil
account.PasswordHash = nil
account.PasswordReset = nil
account.Deleted = true
}
func (account *Account) ResetPassword() error {
var passwordReset uuid.UUID
if err := passwordReset.Generate(uuid.V4); err != nil {