Add _admin_signup mutation

This commit is contained in:
Lakhan Samani
2022-01-09 17:35:37 +05:30
parent 91c35aa381
commit 9d08d6c672
24 changed files with 297 additions and 66 deletions

View File

@@ -134,13 +134,13 @@ func GetAdminAuthToken(gc *gin.Context) (string, error) {
token, err := GetAdminCookie(gc)
if err != nil || token == "" {
// try to check in auth header for cookie
auth := gc.Request.Header.Get("Authorization")
if auth == "" {
return "", fmt.Errorf(`unauthorized`)
}
token = strings.TrimPrefix(auth, "Bearer ")
// auth := gc.Request.Header.Get("Authorization")
// if auth == "" {
// return "", fmt.Errorf(`unauthorized`)
// }
// token = strings.TrimPrefix(auth, "Bearer ")
return "", fmt.Errorf("unauthorized")
}
// cookie escapes special characters like $

View File

@@ -0,0 +1,30 @@
package utils
import (
"encoding/json"
"github.com/authorizerdev/authorizer/server/constants"
)
func EncryptConfig(data map[string]interface{}) ([]byte, error) {
jsonBytes, err := json.Marshal(data)
if err != nil {
return []byte{}, err
}
err = json.Unmarshal(jsonBytes, &constants.EnvData)
if err != nil {
return []byte{}, err
}
configData, err := json.Marshal(constants.EnvData)
if err != nil {
return []byte{}, err
}
encryptedConfig, err := EncryptAES(configData)
if err != nil {
return []byte{}, err
}
return encryptedConfig, nil
}