mirror of https://gitlab.com/ngerakines/tavern.git
debugging issue with init-admin.
This commit is contained in:
parent
94c268ac69
commit
8b54f5c78d
|
@ -11,6 +11,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
|
"github.com/kr/pretty"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
@ -154,8 +155,16 @@ func initAdminCommandAction(cliCtx *cli.Context) error {
|
||||||
// ActorFromUserInfo(name, displayName, domain, publicKey string, privateKey *rsa.PrivateKey) Payload {
|
// ActorFromUserInfo(name, displayName, domain, publicKey string, privateKey *rsa.PrivateKey) Payload {
|
||||||
userActor := storage.ActorFromUserInfo(name, displayName, domain, publicKey, key)
|
userActor := storage.ActorFromUserInfo(name, displayName, domain, publicKey, key)
|
||||||
|
|
||||||
actorID, _ := storage.JSONString(userActor, "id")
|
actorID, hasActorID := storage.JSONString(userActor, "id")
|
||||||
keyID, _ := storage.JSONDeepString(userActor, "publicKey", "id")
|
if !hasActorID || len(actorID) == 0 {
|
||||||
|
pretty.Println(userActor)
|
||||||
|
return fmt.Errorf("missing id from actor")
|
||||||
|
}
|
||||||
|
keyID, hasKeyID := storage.JSONDeepString(userActor, "publicKey", "id")
|
||||||
|
if !hasKeyID || len(keyID) == 0 {
|
||||||
|
pretty.Println(userActor)
|
||||||
|
return fmt.Errorf("missing key id from actor")
|
||||||
|
}
|
||||||
|
|
||||||
err = s.CreateActor(ctx, actorID, userActor)
|
err = s.CreateActor(ctx, actorID, userActor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -235,7 +235,7 @@ func (s pgStorage) RecordActorAlias(ctx context.Context, actorID uuid.UUID, alia
|
||||||
func (s pgStorage) RecordActorKey(ctx context.Context, actorID uuid.UUID, keyID, pem string) error {
|
func (s pgStorage) RecordActorKey(ctx context.Context, actorID uuid.UUID, keyID, pem string) error {
|
||||||
now := s.now()
|
now := s.now()
|
||||||
_, err := s.db.ExecContext(ctx, "INSERT INTO actor_keys (id, actor_id, key_id, pem, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $5) ON CONFLICT ON CONSTRAINT actor_keys_lookup DO UPDATE SET pem = $4, updated_at = $5", NewV4(), actorID, keyID, pem, now)
|
_, err := s.db.ExecContext(ctx, "INSERT INTO actor_keys (id, actor_id, key_id, pem, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $5) ON CONFLICT ON CONSTRAINT actor_keys_lookup DO UPDATE SET pem = $4, updated_at = $5", NewV4(), actorID, keyID, pem, now)
|
||||||
return errors.WrapInsertQueryFailedError(err)
|
return errors.WrapActorKeyInsertFailedError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s pgStorage) ActorsByActorID(ctx context.Context, actorIDs []string) ([]*Actor, error) {
|
func (s pgStorage) ActorsByActorID(ctx context.Context, actorIDs []string) ([]*Actor, error) {
|
||||||
|
|
|
@ -82,6 +82,9 @@ func JSONMap(document map[string]interface{}, key string) (map[string]interface{
|
||||||
if mapVal, isMap := value.(map[string]interface{}); isMap {
|
if mapVal, isMap := value.(map[string]interface{}); isMap {
|
||||||
return mapVal, true
|
return mapVal, true
|
||||||
}
|
}
|
||||||
|
if payloadVal, isPayload := value.(Payload); isPayload {
|
||||||
|
return payloadVal, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
@ -158,6 +161,8 @@ func JSONMapList(document map[string]interface{}, key string) ([]map[string]inte
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
results = append(results, v)
|
results = append(results, v)
|
||||||
|
case Payload:
|
||||||
|
results = append(results, v)
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
for _, el := range v {
|
for _, el := range v {
|
||||||
if mapValue, isMap := el.(map[string]interface{}); isMap {
|
if mapValue, isMap := el.(map[string]interface{}); isMap {
|
||||||
|
|
Loading…
Reference in New Issue