working commit
This commit is contained in:
+25
-27
@@ -10,13 +10,11 @@ import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
func (oper *Operator) ValidateAcount(ctx context.Context, username, password string) (bool, string, error) {
|
||||
func (oper *Operator) ValidatePassword(ctx context.Context, username, password string) (bool, string, error) {
|
||||
var err error
|
||||
var accountID string
|
||||
valid := false
|
||||
|
||||
//oper.WaitRestoring()
|
||||
|
||||
accountExists, accountDescr, err := oper.mdb.GetAccountByUsername(ctx, username)
|
||||
if !accountExists {
|
||||
err := fmt.Errorf("Account not exists")
|
||||
@@ -32,8 +30,8 @@ func (oper *Operator) ValidateAcount(ctx context.Context, username, password str
|
||||
}
|
||||
|
||||
type CreateAccountParams struct {
|
||||
Username string
|
||||
Password string
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
type CreateAccountResult struct {
|
||||
AccountID string `json:"accountId"`
|
||||
@@ -80,11 +78,11 @@ func (oper *Operator) CreateAccount(ctx context.Context, params *CreateAccountPa
|
||||
}
|
||||
|
||||
type UpdateAccountParams struct {
|
||||
Username string
|
||||
AccountID string
|
||||
NewUsername string
|
||||
NewPassword string
|
||||
Disabled bool
|
||||
Username string `json:"username"`
|
||||
AccountID string `json:"accountId"`
|
||||
NewUsername string `json:"newUsername"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
type UpdateAccountResult struct{}
|
||||
|
||||
@@ -137,8 +135,8 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
|
||||
}
|
||||
|
||||
type DeleteAccountParams struct {
|
||||
Username string
|
||||
AccountID string
|
||||
Username string `json:"username"`
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
type DeleteAccountResult struct{}
|
||||
|
||||
@@ -182,13 +180,13 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
|
||||
|
||||
type ListAccountsParams struct{}
|
||||
type ListAccountsResult struct {
|
||||
Accounts []descr.AccountShortDescr `json:"accounts"`
|
||||
Accounts []descr.AccountShort `json:"accounts"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListAccounts(ctx context.Context, params *ListAccountsParams) (*ListAccountsResult, error) {
|
||||
var err error
|
||||
res := &ListAccountsResult{
|
||||
Accounts: make([]descr.AccountShortDescr, 0),
|
||||
Accounts: make([]descr.AccountShort, 0),
|
||||
}
|
||||
|
||||
accountDescrs, err := oper.mdb.ReducedListAccounts(ctx)
|
||||
@@ -196,35 +194,35 @@ func (oper *Operator) ListAccounts(ctx context.Context, params *ListAccountsPara
|
||||
return res, err
|
||||
}
|
||||
for _, accountDescr := range accountDescrs {
|
||||
accountShortDescr := descr.AccountShortDescr{
|
||||
accountShort := descr.AccountShort{
|
||||
Username: accountDescr.Username,
|
||||
Disabled: accountDescr.Disabled,
|
||||
CreatedAt: accountDescr.CreatedAt,
|
||||
UpdatedAt: accountDescr.UpdatedAt,
|
||||
Grants: make([]descr.GrantShortDescr, 0),
|
||||
Grants: make([]descr.GrantShort, 0),
|
||||
}
|
||||
grantDescrs, err := oper.mdb.ListGrantsByAccountID(ctx, accountDescr.ID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
for _, grantDescrs := range grantDescrs {
|
||||
grantShortDescrs := descr.GrantShortDescr{
|
||||
grantShorts := descr.GrantShort{
|
||||
Operation: grantDescrs.Operation,
|
||||
CreatedAt: grantDescrs.CreatedAt,
|
||||
}
|
||||
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
|
||||
accountShort.Grants = append(accountShort.Grants, grantShorts)
|
||||
}
|
||||
res.Accounts = append(res.Accounts, accountShortDescr)
|
||||
res.Accounts = append(res.Accounts, accountShort)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
type GetAccountParams struct {
|
||||
Username string
|
||||
AccountID string
|
||||
Username string `json:"username"`
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
type GetAccountResult struct {
|
||||
Account *descr.AccountShortDescr `json:"account"`
|
||||
Account *descr.AccountShort `json:"account"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
@@ -253,25 +251,25 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
accountShortDescr := &descr.AccountShortDescr{
|
||||
accountShort := &descr.AccountShort{
|
||||
Username: accountDescr.Username,
|
||||
Disabled: accountDescr.Disabled,
|
||||
CreatedAt: accountDescr.CreatedAt,
|
||||
UpdatedAt: accountDescr.UpdatedAt,
|
||||
Grants: make([]descr.GrantShortDescr, 0),
|
||||
Grants: make([]descr.GrantShort, 0),
|
||||
}
|
||||
grantDescrs, err := oper.mdb.ListGrantsByAccountID(ctx, accountDescr.ID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
for _, grantDescrs := range grantDescrs {
|
||||
grantShortDescrs := descr.GrantShortDescr{
|
||||
grantShorts := descr.GrantShort{
|
||||
Operation: grantDescrs.Operation,
|
||||
CreatedAt: grantDescrs.CreatedAt,
|
||||
}
|
||||
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
|
||||
accountShort.Grants = append(accountShort.Grants, grantShorts)
|
||||
}
|
||||
|
||||
res.Account = accountShortDescr
|
||||
res.Account = accountShort
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user