Creating backend to handler password resets

This commit is contained in:
2024-08-21 12:54:25 +02:00
parent 333499f76e
commit b98b61aa76
8 changed files with 77 additions and 6 deletions

View File

@ -280,3 +280,16 @@ func (m *DBModel) Authenticate(email, password string) (int, error) {
return id, nil
}
func (m *DBModel) UpdatePasswordForUser(u User, hash string) error {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
stmt := `UPDATE users SET password = ? where id = ?`
_, err := m.DB.ExecContext(ctx, stmt, hash, u.ID)
if err != nil {
return err
}
return nil
}