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

This commit is contained in:
Julien Dessaux 2025-04-13 09:33:11 +02:00
parent a22b2953e4
commit 2bf1731343
Signed by: adyxax
GPG key ID: F92E51B86E07177E
10 changed files with 230 additions and 12 deletions

View file

@ -49,7 +49,7 @@ func (db *DB) CreateAccount(username string, isAdmin bool) (*model.Account, erro
Id: accountId,
Username: username,
IsAdmin: isAdmin,
PasswordReset: passwordReset,
PasswordReset: &passwordReset,
}, nil
}
@ -91,7 +91,7 @@ func (db *DB) InitAdminAccount() error {
func (db *DB) LoadAccounts() ([]model.Account, error) {
rows, err := db.Query(
`SELECT id, username, salt, password_hash, is_admin, created, last_login, settings FROM accounts;`)
`SELECT id, username, salt, password_hash, is_admin, created, last_login, settings, password_reset FROM accounts;`)
if err != nil {
return nil, fmt.Errorf("failed to load accounts from database: %w", err)
}
@ -111,7 +111,8 @@ func (db *DB) LoadAccounts() ([]model.Account, error) {
&account.IsAdmin,
&created,
&lastLogin,
&account.Settings)
&account.Settings,
&account.PasswordReset)
if err != nil {
return nil, fmt.Errorf("failed to load account from row: %w", err)
}
@ -159,7 +160,7 @@ func (db *DB) LoadAccountById(id uuid.UUID) (*model.Account, error) {
lastLogin int64
)
err := db.QueryRow(
`SELECT username, salt, password_hash, is_admin, created, last_login, settings
`SELECT username, salt, password_hash, is_admin, created, last_login, settings, password_reset
FROM accounts
WHERE id = ?;`,
id,
@ -170,7 +171,7 @@ func (db *DB) LoadAccountById(id uuid.UUID) (*model.Account, error) {
&created,
&lastLogin,
&account.Settings,
)
&account.PasswordReset)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
@ -191,7 +192,7 @@ func (db *DB) LoadAccountByUsername(username string) (*model.Account, error) {
lastLogin int64
)
err := db.QueryRow(
`SELECT id, salt, password_hash, is_admin, created, last_login, settings
`SELECT id, salt, password_hash, is_admin, created, last_login, settings, password_reset
FROM accounts
WHERE username = ?;`,
username,
@ -202,7 +203,7 @@ func (db *DB) LoadAccountByUsername(username string) (*model.Account, error) {
&created,
&lastLogin,
&account.Settings,
)
&account.PasswordReset)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, nil