working commit

This commit is contained in:
2026-02-14 13:14:47 +02:00
parent 7790b70372
commit 4a779007b5
8 changed files with 100 additions and 39 deletions
+35 -2
View File
@@ -72,6 +72,11 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
var err error
res := &GetAccountResult{}
if params.Username == "" && params.AccountID == "" {
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
var accountDescr *descr.Account
var accountExists bool
switch {
@@ -93,6 +98,13 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
default:
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
if accountDescr == nil {
err := fmt.Errorf("Null account desriptor")
return res, err
}
accountShort := &descr.AccountShort{
ID: accountDescr.ID,
@@ -136,7 +148,10 @@ type UpdateAccountResult struct{}
func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountParams) (*UpdateAccountResult, error) {
var err error
res := &UpdateAccountResult{}
if params.Username == "" && params.AccountID == "" {
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
var accountDescr *descr.Account
var accountExists bool
switch {
@@ -158,6 +173,13 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
default:
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
if accountDescr == nil {
err := fmt.Errorf("Null account desriptor")
return res, err
}
now := auxtool.TimeNow()
if params.NewUsername != "" {
@@ -191,6 +213,11 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
var err error
res := &DeleteAccountResult{}
if params.Username == "" && params.AccountID == "" {
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
var accountDescr *descr.Account
var accountExists bool
switch {
@@ -212,8 +239,14 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
default:
err := fmt.Errorf("Empty username and accountId parameter")
return res, err
}
if accountDescr == nil {
err := fmt.Errorf("Null account desriptor")
return res, err
}
err = oper.mdb.DeleteAllGrantsForAccountID(ctx, accountDescr.ID)
if err != nil {
return res, err