mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 06:04:31 -04:00
Fix PR remarks
This commit is contained in:
@@ -31,7 +31,7 @@ interface Client {
|
||||
void set_delegate(ClientDelegate? delegate);
|
||||
|
||||
[Throws=ClientError]
|
||||
void login(string username, string password, string initial_device_name, string? device_id);
|
||||
void login(string username, string password, string? initial_device_name, string? device_id);
|
||||
|
||||
[Throws=ClientError]
|
||||
void restore_login(string restore_token);
|
||||
@@ -181,7 +181,7 @@ interface AuthenticationService {
|
||||
void configure_homeserver(string server_name);
|
||||
|
||||
[Throws=AuthenticationError]
|
||||
Client login(string username, string password, string initial_device_name, string? device_id);
|
||||
Client login(string username, string password, string? initial_device_name, string? device_id);
|
||||
|
||||
[Throws=AuthenticationError]
|
||||
Client restore_with_access_token(string token, string device_id);
|
||||
|
||||
@@ -96,7 +96,7 @@ impl AuthenticationService {
|
||||
&self,
|
||||
username: String,
|
||||
password: String,
|
||||
initial_device_name: String,
|
||||
initial_device_name: Option<String>,
|
||||
device_id: Option<String>,
|
||||
) -> Result<Arc<Client>, AuthenticationError> {
|
||||
let client = match &*self.client.read().unwrap() {
|
||||
|
||||
@@ -64,14 +64,14 @@ impl Client {
|
||||
&self,
|
||||
username: String,
|
||||
password: String,
|
||||
initial_device_name: String,
|
||||
initial_device_name: Option<String>,
|
||||
device_id: Option<String>,
|
||||
) -> anyhow::Result<()> {
|
||||
RUNTIME.block_on(async move {
|
||||
let mut builder = self
|
||||
.client
|
||||
.login_username(&username, &password)
|
||||
.initial_device_display_name(&initial_device_name);
|
||||
let mut builder = self.client.login_username(&username, &password);
|
||||
if let Some(initial_device_name) = initial_device_name.as_ref() {
|
||||
builder = builder.initial_device_display_name(initial_device_name);
|
||||
}
|
||||
if let Some(device_id) = device_id.as_ref() {
|
||||
builder = builder.device_id(device_id);
|
||||
}
|
||||
@@ -290,8 +290,10 @@ impl Client {
|
||||
/// Log out the current user
|
||||
pub fn logout(&self) -> anyhow::Result<()> {
|
||||
RUNTIME.block_on(async move {
|
||||
_ = self.client.logout().await;
|
||||
Ok(())
|
||||
match self.client.logout().await {
|
||||
Ok(_) => Ok(()),
|
||||
Err(error) => Err(anyhow!(error.to_string())),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -302,19 +304,12 @@ impl Client {
|
||||
RumaApiError::ClientApi(error),
|
||||
)))) = sync_error
|
||||
{
|
||||
if matches!(error.kind, ErrorKind::UnknownToken { .. }) {
|
||||
let is_soft_logout = match error.kind {
|
||||
ErrorKind::UnknownToken { soft_logout } => soft_logout,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
self.state.write().unwrap().is_soft_logout = is_soft_logout;
|
||||
|
||||
if let ErrorKind::UnknownToken { soft_logout } = error.kind {
|
||||
self.state.write().unwrap().is_soft_logout = soft_logout;
|
||||
if let Some(delegate) = &*self.delegate.read().unwrap() {
|
||||
delegate.did_update_restore_token();
|
||||
delegate.did_receive_auth_error(is_soft_logout);
|
||||
delegate.did_receive_auth_error(soft_logout);
|
||||
}
|
||||
|
||||
control = LoopCtrl::Break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ struct RestoreToken {
|
||||
is_guest: bool,
|
||||
homeurl: String,
|
||||
session: Session,
|
||||
#[serde(default)]
|
||||
is_soft_logout: bool,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user