🐛 Bug fixes on factor config
This commit is contained in:
parent
fabde24734
commit
71e959805f
@ -25,7 +25,7 @@ type AuthFactor struct {
|
||||
|
||||
Type int8 `json:"type"`
|
||||
Secret string `json:"-"`
|
||||
Config JSONMap `json:"config"`
|
||||
Config datatypes.JSONMap `json:"config"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
@ -8,11 +8,9 @@ import (
|
||||
"git.solsynth.dev/hypernet/passport/pkg/internal/http/exts"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/internal/services"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/pquerna/otp/totp"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
func getAvailableFactors(c *fiber.Ctx) error {
|
||||
@ -121,13 +119,13 @@ func createFactor(c *fiber.Ctx) error {
|
||||
return fmt.Errorf("unable to generate totp key: %v", err)
|
||||
}
|
||||
factor.Secret = key.Secret()
|
||||
factor.Config = datatypes.NewJSONType(map[string]any{
|
||||
factor.Config = map[string]any{
|
||||
"issuer": cfg.Issuer,
|
||||
"account_name": cfg.AccountName,
|
||||
"period": cfg.Period,
|
||||
"secret_size": cfg.SecretSize,
|
||||
"digits": cfg.Digits,
|
||||
})
|
||||
}
|
||||
additionalOnceConfig["url"] = key.URL()
|
||||
}
|
||||
|
||||
@ -136,19 +134,12 @@ func createFactor(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
if len(additionalOnceConfig) > 0 {
|
||||
data := factor.Config.Data()
|
||||
for k, v := range additionalOnceConfig {
|
||||
data[k] = v
|
||||
factor.Config[k] = v
|
||||
}
|
||||
factor.Config = datatypes.NewJSONType(data)
|
||||
}
|
||||
|
||||
var out map[string]any
|
||||
raw, _ := jsoniter.Marshal(factor)
|
||||
jsoniter.Unmarshal(raw, &out)
|
||||
out["config"] = factor.Config.Data()
|
||||
|
||||
return c.JSON(out)
|
||||
return c.JSON(factor)
|
||||
}
|
||||
|
||||
func deleteFactor(c *fiber.Ctx) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user