working commit
This commit is contained in:
@@ -9,10 +9,12 @@ import (
|
||||
"mstore/app/router"
|
||||
)
|
||||
|
||||
func (hand *Handler) CheckGrant(ctx context.Context, accountID, grant, subject string) (bool, error) {
|
||||
func (hand *Handler) CheckRight(ctx context.Context, accountID, right, subject string) (bool, error) {
|
||||
var err error
|
||||
var res bool
|
||||
hand.logg.Debugf("CheckRight %s: %s %s", accountID, right, subject)
|
||||
|
||||
res = true
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -22,9 +24,13 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
|
||||
params := &operator.CreateAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckGrant(rctx.Ctx, operatorID, descr.GrantCreateAccount, params.Username)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, params.Username)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("CreateAccount error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -36,10 +42,6 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
return
|
||||
}
|
||||
res, err := hand.oper.CreateAccount(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("CreateAccount error: %v", err)
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*
|
||||
* This work is published and licensed under a Creative Commons
|
||||
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
*
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
package handler
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user