Fixed app creation, RE: json issue
This commit is contained in:
@@ -339,14 +339,7 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
||||
bodyAddin = ", data=body"
|
||||
|
||||
// FIXME: Does JSON data work?
|
||||
bodyFormatter = `
|
||||
if (body.startswith("{") and body.endswith("}")) or (body.startswith("[") and body.endswith("]")):
|
||||
try:
|
||||
body = json.dumps(body)
|
||||
except:
|
||||
pass
|
||||
`
|
||||
break
|
||||
bodyFormatter = `body = " ".join(body.strip().split())`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,13 +368,14 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
||||
|
||||
// Extra param for url if it's changeable
|
||||
// Extra param for authentication scheme(s)
|
||||
// The last weird one is the body.. Tabs & spaces sucks.
|
||||
data := fmt.Sprintf(` async def %s(self%s%s%s%s%s%s):
|
||||
%s
|
||||
url=f"%s%s"
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
return requests.%s(url, headers=headers%s%s%s).text
|
||||
`,
|
||||
functionname,
|
||||
|
||||
+13
-1
@@ -161,6 +161,7 @@ type User struct {
|
||||
Verified bool `datastore:"verified,noindex" json:"verified"`
|
||||
PrivateApps []WorkflowApp `datastore:"privateapps" json:"privateapps":`
|
||||
Role string `datastore:"role" json:"role"`
|
||||
Roles []string `datastore:"roles" json:"roles"`
|
||||
VerificationToken string `datastore:"verification_token" json:"verification_token"`
|
||||
ApiKey string `datastore:"apikey" json:"apikey"`
|
||||
ResetReference string `datastore:"reset_reference" json:"reset_reference"`
|
||||
@@ -169,7 +170,7 @@ type User struct {
|
||||
Authentication []UserAuth `datastore:"authentication,noindex" json:"authentication"`
|
||||
ResetTimeout int64 `datastore:"reset_timeout,noindex" json:"reset_timeout"`
|
||||
Id string `datastore:"id" json:"id"`
|
||||
Orgs string `datastore:"orgs" json:"orgs"`
|
||||
Orgs []string `datastore:"orgs" json:"orgs"`
|
||||
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
||||
Active bool `datastore:"active" json:"active"`
|
||||
}
|
||||
@@ -1077,12 +1078,15 @@ func handleRegister(resp http.ResponseWriter, request *http.Request) {
|
||||
newUser.Verified = false
|
||||
newUser.CreationTime = time.Now().Unix()
|
||||
newUser.Active = true
|
||||
newUser.Orgs = []string{"default"}
|
||||
|
||||
// FIXME - Remove this later
|
||||
if count == 0 {
|
||||
newUser.Role = "admin"
|
||||
newUser.Roles = []string{"admin"}
|
||||
} else {
|
||||
newUser.Role = "user"
|
||||
newUser.Roles = []string{"user"}
|
||||
}
|
||||
|
||||
// set limits
|
||||
@@ -5953,6 +5957,14 @@ func runInit(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(user.Role) > 0 {
|
||||
user.Roles = append(user.Roles, user.Role)
|
||||
}
|
||||
|
||||
if len(user.Orgs) == 0 {
|
||||
user.Orgs = []string{"default"}
|
||||
}
|
||||
|
||||
err = setUser(ctx, &user)
|
||||
if err != nil {
|
||||
log.Printf("Failed to reset user")
|
||||
|
||||
@@ -2923,8 +2923,8 @@ func getWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
//log.Printf("%#v", parsedApi)
|
||||
log.Printf("API LEN: %d, ID: %s", len(parsedApi.Body), fileId)
|
||||
// log.Printf("%#v", parsedApi)
|
||||
// log.Printf("API LEN: %d, ID: %s", len(parsedApi.Body), fileId)
|
||||
|
||||
//log.Printf("Parsed API: %#v", parsedApi)
|
||||
if len(parsedApi.ID) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user