summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-03-16 07:33:33 +0530
committersinanmohd <sinan@sinanmohd.com>2024-03-16 09:24:06 +0530
commitc6ae7acc13d243f7fcd2115be1da142678e71f70 (patch)
tree7e4be51b816743bcf55d8238b2554856e07e3a4f /db
parentaffa80ee065a41b2afe3a7a12a499a86a88e2950 (diff)
db/Account: Email -> UserName
Diffstat (limited to 'db')
-rw-r--r--db/account.go14
-rw-r--r--db/main.go2
2 files changed, 8 insertions, 8 deletions
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,