From c6ae7acc13d243f7fcd2115be1da142678e71f70 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 16 Mar 2024 07:33:33 +0530 Subject: db/Account: Email -> UserName --- db/account.go | 14 +++++++------- db/main.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'db') 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, -- cgit v1.2.3