working commit

This commit is contained in:
2026-02-19 11:55:17 +02:00
parent 1fd55521de
commit bb0f58f46c
37 changed files with 231 additions and 150 deletions
+35 -34
View File
@@ -13,10 +13,11 @@ package maindb
import (
"context"
"mstore/app/descr"
"mstore/pkg/auxpwd"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/terms"
)
func (db *Database) WriteAnonymous(ctx context.Context) error {
@@ -26,14 +27,14 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
password := auxtool.RandomString(64)
passhash := auxpwd.MakeSHA256Hash([]byte(password))
accountDescr := &descr.Account{
ID: descr.AnonymousID,
Username: descr.AnonimousUsername,
ID: terms.AnonymousID,
Username: terms.AnonimousUsername,
Passhash: passhash,
Disabled: false,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertAccount(ctx, accountDescr)
if err != nil {
@@ -42,12 +43,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadFiles,
Right: terms.RightReadFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -56,12 +57,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadImages,
Right: terms.RightReadImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -75,16 +76,16 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
func (db *Database) WriteInituser(ctx context.Context) error {
var err error
now := auxtool.TimeNow()
passhash := auxpwd.MakeSHA256Hash([]byte(descr.InitUsername))
passhash := auxpwd.MakeSHA256Hash([]byte(terms.InitUsername))
accountDescr := &descr.Account{
ID: descr.InitID,
Username: descr.InitUsername,
ID: terms.InitID,
Username: terms.InitUsername,
Passhash: passhash,
Disabled: false,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertAccount(ctx, accountDescr)
if err != nil {
@@ -94,12 +95,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadFiles,
Right: terms.RightReadFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -108,12 +109,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightWriteFiles,
Right: terms.RightWriteFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -123,12 +124,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadAccounts,
Right: terms.RightReadAccounts,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -137,12 +138,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightWriteAccounts,
Right: terms.RightWriteAccounts,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -152,12 +153,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadImages,
Right: terms.RightReadImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -166,12 +167,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightWriteImages,
Right: terms.RightWriteImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: descr.ServerID,
UpdatedBy: descr.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {