working commit

This commit is contained in:
2026-02-13 15:29:59 +02:00
parent 930df60877
commit 3750b386b1
7 changed files with 89 additions and 46 deletions
+4 -4
View File
@@ -26,7 +26,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
password := auxtool.RandomString(64)
passhash := auxpwd.MakeSHA256Hash([]byte(password))
accountDescr := &descr.Account{
ID: auxuuid.NewUUID(),
ID: descr.AnonymousID,
Username: descr.AnonimousUsername,
Passhash: passhash,
Disabled: false,
@@ -56,7 +56,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadFiles,
Right: descr.RightReadImages,
Pattern: "*",
CreatedAt: now,
UpdatedAt: now,
@@ -78,8 +78,8 @@ func (db *Database) WriteInituser(ctx context.Context) error {
now := auxtool.TimeNow()
passhash := auxpwd.MakeSHA256Hash([]byte(descr.InitUsername))
accountDescr := &descr.Account{
ID: auxuuid.NewUUID(),
Username: descr.AnonimousUsername,
ID: descr.InitID,
Username: descr.InitUsername,
Passhash: passhash,
Disabled: false,
CreatedAt: now,
+3 -3
View File
@@ -76,7 +76,7 @@ const schema = `
CREATE TABLE IF NOT EXISTS grants (
id TEXT NOT NULL,
account_id INT NOT NULL,
operation TEXT NOT NULL,
right TEXT NOT NULL,
pattern TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
@@ -88,8 +88,8 @@ const schema = `
CREATE INDEX IF NOT EXISTS grants_index01
ON grants(account_id);
CREATE INDEX IF NOT EXISTS grants_index02
ON grants(account_id, operation);
ON grants(account_id, right);
CREATE UNIQUE INDEX IF NOT EXISTS grants_index03
ON grants(account_id, operation, pattern);
ON grants(account_id, right, pattern);
`