working commit
This commit is contained in:
+4
-4
@@ -13,7 +13,7 @@ import (
|
||||
"context"
|
||||
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -78,7 +78,7 @@ func (db *Database) GetGrantByID(ctx context.Context, id uuid.UUID) (bool, *desc
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right term.Right) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1`
|
||||
@@ -95,7 +95,7 @@ func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, []descr.Grant, error) {
|
||||
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right term.Right) (bool, []descr.Grant, error) {
|
||||
var err error
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2`
|
||||
res := make([]descr.Grant, 0)
|
||||
@@ -109,7 +109,7 @@ func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uu
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right terms.Right, pattern string) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right term.Right, pattern string) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3 LIMIT 1`
|
||||
|
||||
+34
-34
@@ -16,7 +16,7 @@ import (
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -27,14 +27,14 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
password := auxtool.RandomString(64)
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(password))
|
||||
accountDescr := &descr.Account{
|
||||
ID: terms.AnonymousID,
|
||||
Username: terms.AnonimousUsername,
|
||||
ID: term.AnonymousID,
|
||||
Username: term.AnonimousUsername,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertAccount(ctx, accountDescr)
|
||||
if err != nil {
|
||||
@@ -43,12 +43,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
grantDescr := &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightReadFiles,
|
||||
Right: term.RightReadFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -57,12 +57,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightReadImages,
|
||||
Right: term.RightReadImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -76,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(terms.InitUsername))
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(term.InitUsername))
|
||||
accountDescr := &descr.Account{
|
||||
ID: terms.InitID,
|
||||
Username: terms.InitUsername,
|
||||
ID: term.InitID,
|
||||
Username: term.InitUsername,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertAccount(ctx, accountDescr)
|
||||
if err != nil {
|
||||
@@ -95,12 +95,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr := &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightReadFiles,
|
||||
Right: term.RightReadFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -109,12 +109,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightWriteFiles,
|
||||
Right: term.RightWriteFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -124,12 +124,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightReadAccounts,
|
||||
Right: term.RightReadAccounts,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -138,12 +138,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightWriteAccounts,
|
||||
Right: term.RightWriteAccounts,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -153,12 +153,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightReadImages,
|
||||
Right: term.RightReadImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -167,12 +167,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: terms.RightWriteImages,
|
||||
Right: term.RightWriteImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
CreatedBy: term.ServerID,
|
||||
UpdatedBy: term.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user