Remove refresh token to prevent multiple refresh requests

This commit is contained in:
eraden 2022-05-10 16:32:10 +02:00
parent da218adcbd
commit 17c2997d3d

View File

@ -48,11 +48,14 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
} }
Msg::CheckAccessToken => { Msg::CheckAccessToken => {
orders.skip(); orders.skip();
if model.shared.refresh_token.is_none() {
return;
}
if let Some(exp) = model.shared.exp { if let Some(exp) = model.shared.exp {
if exp > chrono::Utc::now().naive_utc() - chrono::Duration::seconds(1) { if exp > chrono::Utc::now().naive_utc() - chrono::Duration::seconds(1) {
return; return;
} }
if let Some(token) = model.shared.refresh_token.as_ref().cloned() { if let Some(token) = model.shared.refresh_token.take() {
orders.send_msg(Msg::Shared(shared::Msg::RefreshToken(token))); orders.send_msg(Msg::Shared(shared::Msg::RefreshToken(token)));
} }
} }