aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/database/migrations.go2
-rw-r--r--pkg/database/users.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/pkg/database/migrations.go b/pkg/database/migrations.go
index 8d23ed2..8cc6420 100644
--- a/pkg/database/migrations.go
+++ b/pkg/database/migrations.go
@@ -13,7 +13,7 @@ var allMigrations = []func(tx *sql.Tx) error{
CREATE TABLE users (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
- password TEXT,
+ hash TEXT,
email TEXT,
created_at DATE DEFAULT (datetime('now')),
last_login_at DATE DEFAULT NULL
diff --git a/pkg/database/users.go b/pkg/database/users.go
index 10e6416..c7e67e3 100644
--- a/pkg/database/users.go
+++ b/pkg/database/users.go
@@ -13,7 +13,7 @@ func (env *DBEnv) CreateUser(reg *model.UserRegistration) (*model.User, error) {
}
query := `
INSERT INTO users
- (username, password, email)
+ (username, hash, email)
VALUES
($1, $2, $3);`
tx, err := env.db.Begin()
@@ -50,7 +50,7 @@ func (env *DBEnv) CreateUser(reg *model.UserRegistration) (*model.User, error) {
// a PasswordError is return if the passwords do not match
// a QueryError is returned if the username contains invalid sql characters like %
func (env *DBEnv) Login(login *model.UserLogin) (*model.User, error) {
- query := `SELECT id, password, email FROM users WHERE username = $1;`
+ query := `SELECT id, hash, email FROM users WHERE username = $1;`
user := model.User{Username: login.Username}
var hash string
err := env.db.QueryRow(