Add fields necessary for a login with keycard
This commit is contained in:
parent
da5876f632
commit
cee3f70265
|
@ -10,10 +10,12 @@ import (
|
|||
|
||||
// Account stores public information about account.
|
||||
type Account struct {
|
||||
Name string `json:"name"`
|
||||
Address common.Address `json:"address"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
PhotoPath string `json:"photo-path"`
|
||||
Name string `json:"name"`
|
||||
Address common.Address `json:"address"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
PhotoPath string `json:"photo-path"`
|
||||
KeycardPairing string `json:"keycard-pairing"`
|
||||
KeycardKeyUID string `json:"keycard-key-uid"`
|
||||
}
|
||||
|
||||
// InitializeDB creates db file at a given path and applies migrations.
|
||||
|
@ -38,7 +40,7 @@ func (db *Database) Close() error {
|
|||
}
|
||||
|
||||
func (db *Database) GetAccounts() ([]Account, error) {
|
||||
rows, err := db.db.Query("SELECT address, name, loginTimestamp, photoPath from accounts ORDER BY loginTimestamp DESC")
|
||||
rows, err := db.db.Query("SELECT address, name, loginTimestamp, photoPath, keycardPairing, keycardKeyUid from accounts ORDER BY loginTimestamp DESC")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ func (db *Database) GetAccounts() ([]Account, error) {
|
|||
inthelper := sql.NullInt64{}
|
||||
for rows.Next() {
|
||||
acc := Account{}
|
||||
err = rows.Scan(&acc.Address, &acc.Name, &inthelper, &acc.PhotoPath)
|
||||
err = rows.Scan(&acc.Address, &acc.Name, &inthelper, &acc.PhotoPath, &acc.KeycardPairing, &acc.KeycardKeyUID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -57,12 +59,12 @@ func (db *Database) GetAccounts() ([]Account, error) {
|
|||
}
|
||||
|
||||
func (db *Database) SaveAccount(account Account) error {
|
||||
_, err := db.db.Exec("INSERT OR REPLACE INTO accounts (address, name, photoPath) VALUES (?, ?, ?)", account.Address, account.Name, account.PhotoPath)
|
||||
_, err := db.db.Exec("INSERT OR REPLACE INTO accounts (address, name, photoPath, keycardPairing, keycardKeyUid) VALUES (?, ?, ?, ?, ?)", account.Address, account.Name, account.PhotoPath, account.KeycardPairing, account.KeycardKeyUID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) UpdateAccount(account Account) error {
|
||||
_, err := db.db.Exec("UPDATE accounts SET name = ?, photoPath = ? WHERE address = ?", account.Name, account.PhotoPath, account.Address)
|
||||
_, err := db.db.Exec("UPDATE accounts SET name = ?, photoPath = ?, keycardPairing = ?, keycardKeyUid = ? WHERE address = ?", account.Name, account.PhotoPath, account.KeycardPairing, account.KeycardKeyUID, account.Address)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func _0001_accounts_down_sql() ([]byte, error) {
|
|||
)
|
||||
}
|
||||
|
||||
var __0001_accounts_up_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x1c\xcb\x41\x0e\x82\x30\x10\x05\xd0\x7d\x4f\xf1\x97\x9a\x70\x03\x57\x05\xab\x4c\x44\x20\xc3\x20\xb0\x6c\x80\x08\x89\xb4\xc4\xd6\xfb\x9b\x70\x80\x97\xb1\xd1\x62\x20\x3a\x2d\x0c\xe8\x86\xb2\x12\x98\x9e\x1a\x69\x60\xc7\xd1\xff\x5c\x0c\x38\x29\x3b\x4d\xdf\x39\x04\xbc\x34\x67\xb9\x66\xd4\x4c\x4f\xcd\x03\x1e\x66\x48\x94\xb3\xdb\x0c\x31\xbd\x1c\xb8\x6c\x8b\x22\x51\x1f\xff\x5e\x9d\xac\xdb\x1c\xa2\xdd\x76\xa4\x74\x07\x95\x92\xa8\x7d\xf1\xd1\xd7\x36\x2e\x07\x50\x67\x74\x24\x79\xd5\x0a\xb8\xea\xe8\x7a\x51\xff\x00\x00\x00\xff\xff\x14\xa8\x25\xe1\x8f\x00\x00\x00")
|
||||
var __0001_accounts_up_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcb\x31\x8e\x84\x20\x14\x00\xd0\x9e\x53\xfc\x72\x37\xe1\x06\x5b\xa1\xcb\xae\x44\x47\x0d\x7e\x47\x2d\x7f\x84\x28\x99\x11\x8c\x30\x85\xb7\x9f\xc4\x6e\xda\x97\xbc\x5c\x4b\x81\x12\x50\x64\x95\x04\xf5\x07\x75\x83\x20\x47\xd5\x61\x07\x34\xcf\xe1\xe5\x53\x84\x2f\x46\xc6\x1c\x36\x46\xb8\x0b\x9d\x17\x42\x43\xab\xd5\x4d\xe8\x09\x4a\x39\x71\xe6\x69\xb3\x80\x72\xc4\x2b\xd7\x7d\x55\x71\xf6\x0c\x8b\xf3\xe8\x36\x1b\x13\x6d\x3b\x64\xea\x1f\x54\x8d\x9c\xed\x6b\x48\xa1\xa5\xb4\x5e\x81\xb3\x87\x3d\x67\x3a\x4c\x4b\xee\x70\x7e\xf9\xc4\xd2\x9e\xbd\x33\x97\xb1\x6f\x18\x14\x16\x4d\x8f\xa0\x9b\x41\xfd\xfe\xb0\x77\x00\x00\x00\xff\xff\x96\x21\x96\xe1\xb8\x00\x00\x00")
|
||||
|
||||
func _0001_accounts_up_sql() ([]byte, error) {
|
||||
return bindata_read(
|
||||
|
|
|
@ -2,5 +2,7 @@ CREATE TABLE IF NOT EXISTS accounts (
|
|||
address VARCHAR PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
loginTimestamp BIG INT,
|
||||
photoPath TEXT
|
||||
photoPath TEXT,
|
||||
keycardPairing TEXT,
|
||||
keycardKeyUid TEXT
|
||||
) WITHOUT ROWID;
|
||||
|
|
Loading…
Reference in New Issue