Fix session disconnection issue by removing automatic refresh on client initialization
This commit is contained in:
@@ -3,15 +3,13 @@ use crate::matrix_connection::matrix_manager::MatrixManagerMsg;
|
||||
use crate::users::UserEmail;
|
||||
use crate::utils::rand_utils::rand_string;
|
||||
use anyhow::Context;
|
||||
use matrix_sdk::authentication::oauth::error::{
|
||||
BasicErrorResponseType, OAuthDiscoveryError, RequestTokenError,
|
||||
};
|
||||
use matrix_sdk::authentication::oauth::error::OAuthDiscoveryError;
|
||||
use matrix_sdk::authentication::oauth::{
|
||||
ClientId, OAuthError, OAuthSession, UrlOrQuery, UserSession,
|
||||
};
|
||||
use matrix_sdk::encryption::recovery::RecoveryState;
|
||||
use matrix_sdk::ruma::serde::Raw;
|
||||
use matrix_sdk::{Client, ClientBuildError, RefreshTokenError};
|
||||
use matrix_sdk::{Client, ClientBuildError};
|
||||
use ractor::ActorRef;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
@@ -161,20 +159,6 @@ impl MatrixClient {
|
||||
.encryption()
|
||||
.wait_for_e2ee_initialization_tasks()
|
||||
.await;
|
||||
|
||||
// Force token refresh to make sure session is still alive, otherwise disconnect user
|
||||
if let Err(refresh_error) = client.client.oauth().refresh_access_token().await {
|
||||
if let RefreshTokenError::OAuth(e) = &refresh_error
|
||||
&& let OAuthError::RefreshToken(RequestTokenError::ServerResponse(e)) = &**e
|
||||
&& e.error() == &BasicErrorResponseType::InvalidGrant
|
||||
{
|
||||
log::warn!(
|
||||
"Refresh token rejected by server, token must have been invalidated! {refresh_error}"
|
||||
);
|
||||
} else {
|
||||
log::warn!("Failed to refresh token! {refresh_error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically save session when token gets refreshed
|
||||
|
||||
Reference in New Issue
Block a user