1
0
Fork 0
forked from alemi/upub

fix: refresh session only if necessary

This commit is contained in:
əlemi 2024-05-27 07:31:34 +02:00
parent c5b06cd16b
commit 318fa4f670
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -81,6 +81,10 @@ pub async fn refresh(
.await?
.ok_or_else(UpubError::unauthorized)?;
if prev.expires > chrono::Utc::now() {
return Ok(Json(AuthSuccess { token: prev.secret, user: prev.actor, expires: prev.expires }));
}
let token = token();
let expires = chrono::Utc::now() + std::time::Duration::from_secs(3600 * 6);
let user = prev.actor;