From 3feef738dc145603576649a91f0ddc0e82215841 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 27 Jul 2022 15:21:10 +0200 Subject: [PATCH] fix: keep previous refresh token if no new ones were provided --- backend/src/oauth2.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/oauth2.rs b/backend/src/oauth2.rs index fa89b79429..bc7c55dbbe 100644 --- a/backend/src/oauth2.rs +++ b/backend/src/oauth2.rs @@ -454,7 +454,7 @@ pub async fn _refresh_token<'c>( .to_owned(); let token = client - .exchange_refresh_token(&RefreshToken::from(account.refresh_token)) + .exchange_refresh_token(&RefreshToken::from(account.refresh_token.clone())) .with_client(&http_client) .execute::() .await @@ -469,7 +469,7 @@ pub async fn _refresh_token<'c>( ); sqlx::query!( "UPDATE account SET refresh_token = $1, expires_at = $2 WHERE workspace_id = $3 AND id = $4", - token.refresh_token.map(|x| x.to_string()), + token.refresh_token.map(|x| x.to_string()).unwrap_or(account.refresh_token), expires_at, w_id, id