forked from alemi/upub
fix: refresh session only if necessary
This commit is contained in:
parent
c5b06cd16b
commit
318fa4f670
1 changed files with 4 additions and 0 deletions
|
@ -81,6 +81,10 @@ pub async fn refresh(
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(UpubError::unauthorized)?;
|
.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 token = token();
|
||||||
let expires = chrono::Utc::now() + std::time::Duration::from_secs(3600 * 6);
|
let expires = chrono::Utc::now() + std::time::Duration::from_secs(3600 * 6);
|
||||||
let user = prev.actor;
|
let user = prev.actor;
|
||||||
|
|
Loading…
Reference in a new issue