working commit
This commit is contained in:
+24
-2
@@ -1,19 +1,41 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
)
|
||||
|
||||
func (hand *Handler) CheckGrant(ctx context.Context, accountID, grant, subject string) (bool, error) {
|
||||
var err error
|
||||
var res bool
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
// POST /v3/account/create 200 200
|
||||
func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
operatorID := descr.AnonymousID
|
||||
|
||||
params := &operator.CreateAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckGrant(rctx.Ctx, operatorID, descr.GrantCreateAccount, params.Username)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("CreateAccount error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
return
|
||||
}
|
||||
if !opEnable {
|
||||
err := fmt.Errorf("CreateAccount not enabled for this user")
|
||||
hand.SendError(rctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user