writer-framework icon indicating copy to clipboard operation
writer-framework copied to clipboard

It is possible to modify the state from js script?

Open nicolalandro opened this issue 1 year ago • 1 comments

I want to implement a simple login, and I want to create two js function to read and write cookie. I see that globalThis.core.getUserState() get the session state but how to set some variables? Also a code like state.call_frontend_function("mymodule", "sendAlert", ["Bob"]) does return None and not what a js function can return.

Any suggestion for login implementation or in general to interact with js scripts? Must I create a component in this case?

nicolalandro avatar Apr 30 '24 13:04 nicolalandro

Since version 0.6, Writer Framework comes with an authentication module. Could this one meet your requirements?

It is also possible to manage a custom authentication workflow at the fast api level by using the server_setup.py hook to create middleware and routes to manage authentication.

The Writer Framework architecture is designed so that state can be modified exclusively by the backend. The frontend triggers events but cannot modify the state by itself.

Currently, we have not identified a simple way to interact with cookies. Exchanges take place in a websocket stream and not in http requests. This limits the backend's ability to inject a cookie into the request.

FabienArcellier avatar Aug 06 '24 07:08 FabienArcellier

Modifying state from the frontend isn't allowed, as it'd be very unsafe. For authentication, we now have the options provided by @FabienArcellier .

ramedina86 avatar Aug 26 '24 08:08 ramedina86