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),
|
||||
|
||||
Reference in New Issue
Block a user