Authentication fixes to workflow imports

This commit is contained in:
frikky
2020-10-05 11:37:11 +02:00
parent 6ebebe8795
commit 0f5f97a837
2 changed files with 28 additions and 12 deletions
+14 -7
View File
@@ -1585,7 +1585,8 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
}
// FIXME: Have a good way of tracking errors. ID's or similar.
if !action.IsValid {
if !action.IsValid && len(action.Errors) > 0 {
log.Printf("Node %s is invalid and needs to be remade. Errors: %s", action.Label, strings.Join(action.Errors, "\n"))
resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Node %s is invalid and needs to be remade."}`, action.Label)))
return
@@ -1792,10 +1793,16 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
}
if !authFound {
log.Printf("App auth %s doesn't exist", action.AuthenticationId)
resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "App auth %s doesn't exist"}`, action.AuthenticationId)))
return
log.Printf("App auth %s doesn't exist. Setting error", action.AuthenticationId)
workflow.Errors = append(workflow.Errors, fmt.Sprintf("App authentication for %s doesn't exist!", action.AppName))
workflow.IsValid = false
action.Errors = append(action.Errors, "App authentication doesn't exist")
action.IsValid = false
action.AuthenticationId = ""
//resp.WriteHeader(401)
//resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "App auth %s doesn't exist"}`, action.AuthenticationId)))
//return
}
}
@@ -2421,9 +2428,9 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
for _, authparam := range curAuth.Fields {
if param.Name == authparam.Key {
log.Printf("Name: %s - value: %s", param.Name, param.Value)
param.Value = authparam.Value
log.Printf("Name: %s - value: %s\n", param.Name, param.Value)
//log.Printf("Name: %s - value: %s", param.Name, param.Value)
//log.Printf("Name: %s - value: %s\n", param.Name, param.Value)
break
}
}
+14 -5
View File
@@ -558,6 +558,10 @@ const AngularWorkflow = (props) => {
}
}
// Override just in this place
curworkflowAction.errors = []
curworkflowAction.isValid = true
newActions.push(curworkflowAction)
} else if (type === "TRIGGER") {
//console.log("TRIGGER")
@@ -2258,6 +2262,7 @@ const AngularWorkflow = (props) => {
const ParsedAppPaper = (props) => {
const app = props.app
const [hover, setHover] = React.useState(false)
// FIXME - add label to apps, as this might be slow with A LOT of apps
var newAppname = app.name
@@ -2268,6 +2273,10 @@ const AngularWorkflow = (props) => {
}
const image = "url("+app.large_image+")"
const newAppStyle = JSON.parse(JSON.stringify(paperAppStyle))
const pixelSize = !hover ? "2px" : "4px"
newAppStyle.borderLeft = app.is_valid ? `${pixelSize} solid green` : `${pixelSize} solid orange`
return (
<Draggable
@@ -2280,10 +2289,8 @@ const AngularWorkflow = (props) => {
y: 0,
}}
>
<Paper square style={paperAppStyle} >
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: "2px", backgroundColor: "orange", marginRight: "5px"}}>
</div>
<Grid container style={{margin: "10px 10px 10px 10px", flex: "10"}}>
<Paper square style={newAppStyle} onMouseOver={() => {setHover(true)}} onMouseOut={() => {setHover(false)}}>
<Grid container style={{margin: "10px 10px 10px 15px", flex: "10"}}>
<Grid item>
<div style={{borderRadius: borderRadius, height: 80, width: 80, backgroundImage: image, backgroundSize: "cover", backgroundRepeat: "no-repeat"}} />
</Grid>
@@ -5838,7 +5845,7 @@ const AngularWorkflow = (props) => {
}
const handleSubmitCheck = () => {
console.log(authenticationOption)
console.log("NEW AUTH: ", authenticationOption)
if (authenticationOption.label.length === 0) {
alert.info("Label can't be empty")
return
@@ -5869,6 +5876,8 @@ const AngularWorkflow = (props) => {
console.log("FIELDS: ", newFields)
newAuthOption.fields = newFields
setNewAppAuth(newAuthOption)
appAuthentication.push(newAuthOption)
setAppAuthentication(appAuthentication)
setUpdate(authenticationOption.id)
}