summaryrefslogtreecommitdiff
path: root/db/user.go
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-02 14:00:28 -0500
committersanine-a <sanine.not@pm.me>2023-05-02 14:00:28 -0500
commit9fe48ae66c2cc8d6b46e44ae35e9447ab51d9dd6 (patch)
tree94aff558aedaf3c1f7452983887b6f3479c9cef7 /db/user.go
parent4343925a09c1fd34da4b352ae9fa2510397ccdcd (diff)
add user.go
Diffstat (limited to 'db/user.go')
-rw-r--r--db/user.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/user.go b/db/user.go
index c1f2efe..61e05ad 100644
--- a/db/user.go
+++ b/db/user.go
@@ -78,6 +78,13 @@ func (p *Phlox) CreateUser(username, password string) (User, error) {
+func (p *Phlox) DeleteUser(user User) error {
+ _, err := p.db.Exec("delete from users where userid=?;", user.Id)
+ return err
+}
+
+
+
func (p *Phlox) SetPassword(user User, password string) error {
hash, err := hashPassword(password, user.Salt)
if err != nil {
@@ -140,6 +147,16 @@ func (p *Phlox) AuthenticateUser(username, password string) (bool, User, error)
}
+func (p *Phlox) GetByUsername(username string) (User, error) {
+ row := p.db.QueryRow("select * from users where username = ?;", username)
+ user, err := extractUser(row)
+ if err != nil {
+ return User{}, err
+ }
+ return user, nil
+}
+
+
func (p *Phlox) GetById(id int) (User, error) {
row := p.db.QueryRow("select * from users where userid = ?;", id)
user, err := extractUser(row)