working commit
This commit is contained in:
+26
-14
@@ -100,15 +100,19 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
|
||||
return res, err
|
||||
}
|
||||
case params.Username != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with this is or name dont exists")
|
||||
return res, err
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
now := auxtool.TimeNow()
|
||||
if params.NewUsername != "" {
|
||||
@@ -150,15 +154,19 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
|
||||
return res, err
|
||||
}
|
||||
case params.Username != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with this is or name dont exists")
|
||||
return res, err
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
|
||||
err = oper.mdb.DeleteAllGrantsForAccountID(ctx, accountDescr.ID)
|
||||
@@ -216,7 +224,7 @@ type GetAccountParams struct {
|
||||
AccountID string
|
||||
}
|
||||
type GetAccountResult struct {
|
||||
Account *descr.AccountShortDescr `json:"accountDescr"`
|
||||
Account *descr.AccountShortDescr `json:"account"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
@@ -227,19 +235,23 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.Username)
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
|
||||
return res, err
|
||||
}
|
||||
case params.Username != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with this is or name dont exists")
|
||||
return res, err
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account with name %s dont exists", params.Username)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
accountShortDescr := &descr.AccountShortDescr{
|
||||
Username: accountDescr.Username,
|
||||
|
||||
Reference in New Issue
Block a user