Start a new topic

How can component in xap know the exaptive user running the xap?


How can a component figure out if there is a currently logged in exaptive user, and the username?


1 person likes this idea

Hey Dave,

To check if someone has an Auth token you can check `localStorage.exaptive_access_token`, but it has the chance of being an expired token. And to get the UUID of the user whom the auth token belongs to check `localStorage.exaptive_uuid`.

Hope that helped.

Accessing data stored in localStorage by the exaptive client sounds like something that should not be done directly by component authors as it then becomes de facto API and difficult to change later on.  Providing an API call to retrieve the currently logged in user would be a better option.

An API call to retrieve the currently authenticated user exists, but I'm not sure that information is correctly passed to running Xaps outside of our Frontend, nor am I sure if it should be. So making that API call would require the token to be used from local storage.

Edit: I might clarify, we handle sessions using JWT. Currently they are stored in localStorage, but regardless of where they are stored they need to be attached to the request retrieving who is currently authenticated.

Edit 2: I also agree, using local storage is not a viable long term solution, but I think it might be the only way right now.

Login to post a comment