Help getting Server Response to work

I am trying to detect if user is logged in and redirect if they are but i am facing a strange issue which is hard to explain.

I added the Security Identity to the SA and want to make a Condition which outputs ‘200 Success’ to trigger a Dynamic Event to redirect.
I get the output in console, code 200 and the TEXT but event in not triggered. and the ‘he’ Value is not outputted on the page. This is a test step which i know i don’t need but helps with debuging.
If i disable the Condition. the value of ‘he’ is outputted to the page. I don’t understand this.

If i reverse the condition and set a response 403(or whatever), if user IS logged in it finishes the action, sends 200 (on its own) and Dynamic event is triggered.

This doesn’t work( no event trigger on success) :

2

This works (triggers on success event):
no

The above works but i feel is wrong. also Dynamic event Unauthorized wont detect that either. But i only need it to be a success.

So i feel my Responses are not right.

any ideas?

Ok i removed the condition from the Server Action and added a FLOW with Condition to the Dynamic Event to check if Identity has value and redirect.

Was not able to get response> dynamic event to work

A response step overrides every other output in the server action.
You can bind the text part of response to contain any variables you want in output. But the kind of data that can be added is limited.
For your case, you can just not do anything in the “true” step. Just put in a comment and keep the else as response. So if condition is true, you will see the set value in output, else 403.

Also, from a security perspective, you should not expose the logged in user’s ID on the client side. For 99% of the cases, its not required.

1 Like

Thanks I had a feeling it was overriding everything else.

But why would my response 200 not trigger a dynamic event ‘on success’. Whereas ‘doing nothing’ as u said does trigger it.

I don’t need to output any values just need it to generate 200 response. Which your comment idea does.

Thanks

That could be a bug. Have not seen this before. It should trigger 200.

No, it’s not a bug.
The response is not a valid JSON and that is the problem.
If you want to use it with a server connect component then it should return valid json, try to return true , null or "some string" .

1 Like

The screenshot up top suggests he bound the response with successtest. Should it be "success test" to invoke SC's success event?

Yes the value is wrong / not a valid json, which triggers an error. It needs to be formatted as per my explanation above.

Ok sorry about that!

I had tried ‘string’ but same issue
Didn’t think to use " ". never had to use that format anywhere else in wappler yet.

learning something new everyday!