summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-29 16:10:59 +0530
committerAndinus <andinus@nand.sh>2020-03-29 16:10:59 +0530
commita6826055bf4e6a23f80da047ccfe4509a209f3a6 (patch)
treef2bb2bec35ee5e61cb42f4edffb04368a0f8ba60 /user
parent7b95d6b80dd2d1efb26f7c515383abd4f0dc9d42 (diff)
downloadperseus-a6826055bf4e6a23f80da047ccfe4509a209f3a6.tar.gz
Initial perseus rewrite
Diffstat (limited to 'user')
-rw-r--r--user/adduser.go42
-rw-r--r--user/getid.go29
-rw-r--r--user/user.go9
3 files changed, 0 insertions, 80 deletions
diff --git a/user/adduser.go b/user/adduser.go
deleted file mode 100644
index d1dbcde..0000000
--- a/user/adduser.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package user
-
-import (
-	"log"
-	"time"
-
-	"tildegit.org/andinus/perseus/storage/sqlite3"
-)
-
-// AddUser adds the user to record.
-func (u User) AddUser(db *sqlite3.DB) error {
-	// Acquire write lock on the database.
-	db.Mu.Lock()
-	defer db.Mu.Unlock()
-
-	// Start the transaction
-	tx, err := db.Conn.Begin()
-	if err != nil {
-		log.Printf("user/adduser.go: %s\n",
-			"failed to begin transaction")
-		return err
-	}
-
-	usrStmt, err := db.Conn.Prepare(`
-INSERT INTO users(id, username, password, regTime) values(?, ?, ?, ?)`)
-	if err != nil {
-		log.Printf("user/adduser.go: %s\n",
-			"failed to prepare statement")
-		return err
-	}
-	defer usrStmt.Close()
-
-	_, err = usrStmt.Exec(u.ID, u.Username, u.Password, time.Now().UTC())
-	if err != nil {
-		log.Printf("user/adduser.go: %s\n",
-			"failed to execute statement")
-		return err
-	}
-
-	tx.Commit()
-	return err
-}
diff --git a/user/getid.go b/user/getid.go
deleted file mode 100644
index 9cf8870..0000000
--- a/user/getid.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package user
-
-import (
-	"log"
-
-	"tildegit.org/andinus/perseus/storage/sqlite3"
-)
-
-// GetID returns id from username.
-func (u *User) GetID(db *sqlite3.DB) error {
-	// Get password for this user from the database.
-	stmt, err := db.Conn.Prepare("SELECT id FROM users WHERE username = ?")
-	if err != nil {
-		log.Printf("user/getid.go: %s\n",
-			"failed to prepare statement")
-		return err
-	}
-	defer stmt.Close()
-
-	var id string
-	err = stmt.QueryRow(u.Username).Scan(&id)
-	if err != nil {
-		log.Printf("user/getid.go: %s\n",
-			"query failed")
-	}
-	u.ID = id
-
-	return err
-}
diff --git a/user/user.go b/user/user.go
deleted file mode 100644
index 078215e..0000000
--- a/user/user.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package user
-
-// User holds information about the user.
-type User struct {
-	ID       string
-	Username string
-	Password string
-	Hash     string
-}