mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 13:57:32 +00:00
28 lines
500 B
Go
28 lines
500 B
Go
|
package systemapi
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"reflect"
|
||
|
|
||
|
"github.com/zitadel/zitadel/internal/api/authz"
|
||
|
)
|
||
|
|
||
|
type Users map[string]*authz.SystemAPIUser
|
||
|
|
||
|
func UsersDecodeHook(from, to reflect.Value) (any, error) {
|
||
|
if to.Type() != reflect.TypeOf(Users{}) {
|
||
|
return from.Interface(), nil
|
||
|
}
|
||
|
|
||
|
data, ok := from.Interface().(string)
|
||
|
if !ok {
|
||
|
return from.Interface(), nil
|
||
|
}
|
||
|
users := make(Users)
|
||
|
err := json.Unmarshal([]byte(data), &users)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return users, nil
|
||
|
}
|