summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/redqctl/main.go4
-rw-r--r--db/account.go14
-rw-r--r--db/main.go2
3 files changed, 10 insertions, 10 deletions
diff --git a/cmd/redqctl/main.go b/cmd/redqctl/main.go
index f6f9e9e..e60ea85 100644
--- a/cmd/redqctl/main.go
+++ b/cmd/redqctl/main.go
@@ -32,8 +32,8 @@ func create(args []string, db *redqdb.SafeDB) {
ac := &redqdb.Account{}
ac.Info = &redqdb.Login{}
- f.StringVar(&ac.Email, "email", "",
- "The email to associate with the account")
+ f.StringVar(&ac.UserName, "username", "",
+ "The username to associate with the account")
f.StringVar(&ac.Info.FirstName, "fname", "",
"The first name to associate with the account")
f.StringVar(&ac.Info.LastName, "lname", "",
diff --git a/db/account.go b/db/account.go
index 2c99045..b7bcaa0 100644
--- a/db/account.go
+++ b/db/account.go
@@ -3,7 +3,7 @@ package db
import "errors"
type Account struct {
- Email string
+ UserName string
PassHash string
Info *Login
@@ -20,7 +20,7 @@ func (ac *Account) CreateAccount(safe *SafeDB) error {
const sqlStatement string = `
INSERT INTO Accounts (
id,
- Email,
+ UserName,
PassHash,
Level,
FirstName,
@@ -34,7 +34,7 @@ func (ac *Account) CreateAccount(safe *SafeDB) error {
_, err := safe.db.Exec(
sqlStatement,
- ac.Email,
+ ac.UserName,
ToBlake3(ac.PassHash),
ac.Info.FirstName,
@@ -49,13 +49,13 @@ func (ac *Account) Login(safe *SafeDB) error {
const sqlStatementQuery string = `
SELECT id, PassHash, Level, FirstName, LastName
FROM Accounts
- WHERE Accounts.Email = ?
+ WHERE Accounts.UserName = ?
`
ac.Info = &Login{}
ac.Info.Bearer = &Bearer{}
safe.mu.Lock()
- row := safe.db.QueryRow(sqlStatementQuery, ac.Email)
+ row := safe.db.QueryRow(sqlStatementQuery, ac.UserName)
safe.mu.Unlock()
var PassHash string
@@ -83,7 +83,7 @@ func (ac *Account) Login(safe *SafeDB) error {
func (ac *Account) fromBearer(safe *SafeDB, b *Bearer) error {
const sqlStatementAccount string = `
- SELECT Email, PassHash, Level, FirstName, LastName
+ SELECT UserName, PassHash, Level, FirstName, LastName
FROM Accounts
WHERE Accounts.id = ?
`
@@ -96,7 +96,7 @@ func (ac *Account) fromBearer(safe *SafeDB, b *Bearer) error {
ac.Info.id = b.accountId
ac.Info.Bearer = b
err := row.Scan(
- &ac.Email,
+ &ac.UserName,
&ac.PassHash,
&ac.Info.FirstName,
diff --git a/db/main.go b/db/main.go
index c78ea3a..801cb65 100644
--- a/db/main.go
+++ b/db/main.go
@@ -33,7 +33,7 @@ func NewSafeDB() (*SafeDB, error) {
const create string = `
CREATE TABLE IF NOT EXISTS Accounts(
id INTEGER PRIMARY KEY,
- Email CHAR(64) NOT NULL UNIQUE,
+ UserName CHAR(64) NOT NULL UNIQUE,
PassHash CHAR(128) NOT NULL,
Level INTEGER NOT NULL,