Replies: 2 comments 3 replies
-
Hm yeah I'm not great with the details of JWT. What's the flow that you actually need to do to renew a token? Is it something you can verify on the server, and renew from the server if it needs to be renewed? In that case something like a Worth checking out the |
Beta Was this translation helpful? Give feedback.
-
So... I didn't find a very elegant way of doing it but here is where I am at the moment and it works pretty well. I have a global state context which looks like this: #[derive(Debug, Clone, Copy, PartialEq)]
pub struct GlobalState {
pub logged_in_user: RwSignal<Option<LoggedInUser>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LoggedInUser {
access_token: String,
access_token_exp: DateTime<Utc>,
auth_token: String,
auth_token_exp: DateTime<Utc>,
} and basically what I do is just a call to |
Beta Was this translation helpful? Give feedback.
-
When one is accessing an API with authentication, what is the best way to handle HTTP Authentication and token renewal?
My first guess was using a context with a RwSignal and running a background task, dedicated to token renewal when it expires. It seems a bit far from the philosophy of leptos; so I was wondering if any of you have ever asked yourself this question and found an elegant way to answer it :)
I started using leptos a few days ago and I'm completely seduced ; I hope there's a solution to do this.
Beta Was this translation helpful? Give feedback.
All reactions