working commit
This commit is contained in:
@@ -76,6 +76,23 @@ func (db *Database) GetGrantByID(ctx context.Context, id string) (bool, *descr.G
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID, right string) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1`
|
||||
dbRes := make([]descr.Grant, 0)
|
||||
err = db.db.Select(&dbRes, request, accountID, right)
|
||||
if err != nil {
|
||||
return false, res, err
|
||||
}
|
||||
if len(dbRes) == 0 {
|
||||
return false, res, err
|
||||
|
||||
}
|
||||
res = &dbRes[0]
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID, right, pattern string) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestGrant(t *testing.T) {
|
||||
newGrant := &descr.Grant{
|
||||
ID: id,
|
||||
AccountID: accountID,
|
||||
Operation: "opFoo",
|
||||
Right: "rigthFoo",
|
||||
Pattern: `*`,
|
||||
CreatedAt: timenow,
|
||||
UpdatedAt: timenow,
|
||||
|
||||
+6
-6
@@ -43,7 +43,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadFiles,
|
||||
Pattern: "*",
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
@@ -57,7 +57,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadImages,
|
||||
Pattern: "*",
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
@@ -96,7 +96,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadFiles,
|
||||
Pattern: "*",
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
@@ -110,7 +110,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteFiles,
|
||||
Pattern: "*",
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
@@ -125,7 +125,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadImages,
|
||||
Pattern: "*",
|
||||
Pattern: ",*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
@@ -139,7 +139,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteImages,
|
||||
Pattern: "*",
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
|
||||
Reference in New Issue
Block a user