working commit
This commit is contained in:
+11
-11
@@ -5,15 +5,15 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mbase/app/descr"
|
||||
"mbase/pkg/auxid"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/auxpwd"
|
||||
"mbase/pkg/mbctl"
|
||||
)
|
||||
|
||||
func (lg *Logic) ValidateAcount(ctx context.Context, username, password string) (bool, int64, error) {
|
||||
func (lg *Logic) ValidateAcount(ctx context.Context, username, password string) (bool, string, error) {
|
||||
var err error
|
||||
var accountID int64
|
||||
var accountID string
|
||||
var valid bool
|
||||
|
||||
lg.WaitRestoring()
|
||||
@@ -32,7 +32,7 @@ func (lg *Logic) ValidateAcount(ctx context.Context, username, password string)
|
||||
return valid, accountID, err
|
||||
}
|
||||
|
||||
func (lg *Logic) CreateAccount(ctx context.Context, accountID int64, params *mbctl.CreateAccountParams) (*mbctl.CreateAccountResult, error) {
|
||||
func (lg *Logic) CreateAccount(ctx context.Context, accountID string, params *mbctl.CreateAccountParams) (*mbctl.CreateAccountResult, error) {
|
||||
var err error
|
||||
res := &mbctl.CreateAccountResult{}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (lg *Logic) CreateAccount(ctx context.Context, accountID int64, params *mbc
|
||||
now := time.Now().Format(time.RFC3339)
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
|
||||
accountDescr := &descr.Account{
|
||||
ID: auxid.GenID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Username: params.Username,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
@@ -83,7 +83,7 @@ func (lg *Logic) CreateAccount(ctx context.Context, accountID int64, params *mbc
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (lg *Logic) UpdateAccount(ctx context.Context, accountID int64, params *mbctl.UpdateAccountParams) (*mbctl.UpdateAccountResult, error) {
|
||||
func (lg *Logic) UpdateAccount(ctx context.Context, accountID string, params *mbctl.UpdateAccountParams) (*mbctl.UpdateAccountResult, error) {
|
||||
var err error
|
||||
res := &mbctl.UpdateAccountResult{}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (lg *Logic) UpdateAccount(ctx context.Context, accountID int64, params *mbc
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = lg.db.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -140,7 +140,7 @@ func (lg *Logic) UpdateAccount(ctx context.Context, accountID int64, params *mbc
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (lg *Logic) DeleteAccount(ctx context.Context, accountID int64, params *mbctl.DeleteAccountParams) (*mbctl.DeleteAccountResult, error) {
|
||||
func (lg *Logic) DeleteAccount(ctx context.Context, accountID string, params *mbctl.DeleteAccountParams) (*mbctl.DeleteAccountResult, error) {
|
||||
var err error
|
||||
res := &mbctl.DeleteAccountResult{}
|
||||
|
||||
@@ -159,7 +159,7 @@ func (lg *Logic) DeleteAccount(ctx context.Context, accountID int64, params *mbc
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = lg.db.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -186,7 +186,7 @@ func (lg *Logic) DeleteAccount(ctx context.Context, accountID int64, params *mbc
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (lg *Logic) ListAccounts(ctx context.Context, accountID int64, params *mbctl.ListAccountsParams) (*mbctl.ListAccountsResult, error) {
|
||||
func (lg *Logic) ListAccounts(ctx context.Context, accountID string, params *mbctl.ListAccountsParams) (*mbctl.ListAccountsResult, error) {
|
||||
var err error
|
||||
res := &mbctl.ListAccountsResult{
|
||||
Accounts: make([]*mbctl.AccountShortDescr, 0),
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"mbase/app/descr"
|
||||
"mbase/pkg/auxid"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/auxpwd"
|
||||
)
|
||||
|
||||
@@ -23,9 +23,9 @@ func (lg *Logic) CleanDatabase(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (lg *Logic) SeedAccount(ctx context.Context) (int64, error) {
|
||||
func (lg *Logic) SeedAccount(ctx context.Context) (string, error) {
|
||||
var err error
|
||||
var accountID int64
|
||||
var accountID string
|
||||
accountDescrs, err := lg.db.ReducedListAccounts(ctx)
|
||||
if err != nil {
|
||||
return accountID, err
|
||||
@@ -35,7 +35,7 @@ func (lg *Logic) SeedAccount(ctx context.Context) (int64, error) {
|
||||
now := time.Now().Format(time.RFC3339)
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(defaultSeedPassword))
|
||||
accountDescr := &descr.Account{
|
||||
ID: auxid.GenID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Username: defaultSeedUsername,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
@@ -63,9 +63,7 @@ func (lg *Logic) SeedAccount(ctx context.Context) (int64, error) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return accountID, err
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,13 +5,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mbase/app/descr"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/mbctl"
|
||||
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
func (lg *Logic) GetDump(ctx context.Context, accountID int64, params *mbctl.GetDumpParams) (*mbctl.GetDumpResult, error) {
|
||||
func (lg *Logic) GetDump(ctx context.Context, accountID string, params *mbctl.GetDumpParams) (*mbctl.GetDumpResult, error) {
|
||||
var err error
|
||||
res := &mbctl.GetDumpResult{}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (lg *Logic) GetDump(ctx context.Context, accountID int64, params *mbctl.Get
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (lg *Logic) RestoreDump(ctx context.Context, accountID int64, params *mbctl.RestoreDumpParams) (*mbctl.RestoreDumpResult, error) {
|
||||
func (lg *Logic) RestoreDump(ctx context.Context, accountID string, params *mbctl.RestoreDumpParams) (*mbctl.RestoreDumpResult, error) {
|
||||
var err error
|
||||
res := &mbctl.RestoreDumpResult{}
|
||||
|
||||
|
||||
+7
-7
@@ -5,12 +5,12 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mbase/app/descr"
|
||||
"mbase/pkg/auxid"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/mbctl"
|
||||
)
|
||||
|
||||
func (lg *Logic) SetGrant(ctx context.Context, accountID int64, params *mbctl.SetGrantParams) (*mbctl.SetGrantResult, error) {
|
||||
func (lg *Logic) SetGrant(ctx context.Context, accountID string, params *mbctl.SetGrantParams) (*mbctl.SetGrantResult, error) {
|
||||
var err error
|
||||
res := &mbctl.SetGrantResult{}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (lg *Logic) SetGrant(ctx context.Context, accountID int64, params *mbctl.Se
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = lg.db.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -70,7 +70,7 @@ func (lg *Logic) SetGrant(ctx context.Context, accountID int64, params *mbctl.Se
|
||||
}
|
||||
now := time.Now().Format(time.RFC3339)
|
||||
grantDescr := &descr.Grant{
|
||||
ID: auxid.GenID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
CreatedAt: now,
|
||||
Operation: params.Operation,
|
||||
@@ -82,7 +82,7 @@ func (lg *Logic) SetGrant(ctx context.Context, accountID int64, params *mbctl.Se
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (lg *Logic) DeleteGrant(ctx context.Context, accountID int64, params *mbctl.DeleteGrantParams) (*mbctl.DeleteGrantResult, error) {
|
||||
func (lg *Logic) DeleteGrant(ctx context.Context, accountID string, params *mbctl.DeleteGrantParams) (*mbctl.DeleteGrantResult, error) {
|
||||
var err error
|
||||
res := &mbctl.DeleteGrantResult{}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (lg *Logic) DeleteGrant(ctx context.Context, accountID int64, params *mbctl
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = lg.db.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
||||
Reference in New Issue
Block a user