mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
verify currency
This commit is contained in:
@@ -141,6 +141,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot have any sub accounts")
|
||||
return nil, errs.ErrAccountCannotHaveSubAccounts
|
||||
}
|
||||
|
||||
if accountCreateReq.Currency == validators.ParentAccountCurrencyPlaceholder {
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot set currency placeholder")
|
||||
return nil, errs.ErrAccountCurrencyInvalid
|
||||
}
|
||||
} else if accountCreateReq.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
|
||||
if len(accountCreateReq.SubAccounts) < 1 {
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account does not have any sub accounts")
|
||||
@@ -169,6 +174,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account type invalid")
|
||||
return nil, errs.ErrSubAccountTypeInvalid
|
||||
}
|
||||
|
||||
if subAccount.Currency == validators.ParentAccountCurrencyPlaceholder {
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account cannot set currency placeholder")
|
||||
return nil, errs.ErrAccountCurrencyInvalid
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account type invalid, type is %d", accountCreateReq.Type)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/mayswind/lab/pkg/models"
|
||||
"github.com/mayswind/lab/pkg/services"
|
||||
"github.com/mayswind/lab/pkg/settings"
|
||||
"github.com/mayswind/lab/pkg/validators"
|
||||
)
|
||||
|
||||
// UsersApi represents user api
|
||||
@@ -40,6 +41,11 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
|
||||
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
|
||||
}
|
||||
|
||||
if userRegisterReq.DefaultCurrency == validators.ParentAccountCurrencyPlaceholder {
|
||||
log.WarnfWithRequestId(c, "[users.UserRegisterHandler] user default currency is invalid")
|
||||
return nil, errs.ErrUserDefaultCurrencyIsInvalid
|
||||
}
|
||||
|
||||
userRegisterReq.Username = strings.TrimSpace(userRegisterReq.Username)
|
||||
userRegisterReq.Email = strings.TrimSpace(userRegisterReq.Email)
|
||||
userRegisterReq.Nickname = strings.TrimSpace(userRegisterReq.Nickname)
|
||||
|
||||
Reference in New Issue
Block a user