Skip to content

Commit f311cae

Browse files
authored
fix: Parse login scheme in add_transport_from_qr() (#6802)
fix #6801
1 parent 7e8e4d2 commit f311cae

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/configure.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use crate::login_param::{
3636
use crate::message::Message;
3737
use crate::oauth2::get_oauth2_addr;
3838
use crate::provider::{Protocol, Provider, Socket, UsernamePattern};
39-
use crate::qr::set_account_from_qr;
4039
use crate::smtp::Smtp;
4140
use crate::sync::Sync::*;
4241
use crate::tools::time;
@@ -160,8 +159,19 @@ impl Context {
160159
pub async fn add_transport_from_qr(&self, qr: &str) -> Result<()> {
161160
self.stop_io().await;
162161

162+
// This code first sets the deprecated Config::Addr, Config::MailPw, etc.
163+
// and then calls configure(), which loads them again.
164+
// At some point, we will remove configure()
165+
// and then simplify the code
166+
// to directly create an EnteredLoginParam.
163167
let result = async move {
164-
set_account_from_qr(self, qr).await?;
168+
match crate::qr::check_qr(self, qr).await? {
169+
crate::qr::Qr::Account { .. } => crate::qr::set_account_from_qr(self, qr).await?,
170+
crate::qr::Qr::Login { address, options } => {
171+
crate::qr::configure_from_login_qr(self, &address, options).await?
172+
}
173+
_ => bail!("QR code does not contain account"),
174+
}
165175
self.configure().await?;
166176
Ok(())
167177
}

src/qr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use deltachat_contact_tools::{addr_normalize, may_be_valid_addr, ContactAddress}
1010
use percent_encoding::{percent_decode_str, percent_encode, NON_ALPHANUMERIC};
1111
use serde::Deserialize;
1212

13-
use self::dclogin_scheme::configure_from_login_qr;
13+
pub(crate) use self::dclogin_scheme::configure_from_login_qr;
1414
use crate::chat::ChatIdBlocked;
1515
use crate::config::Config;
1616
use crate::constants::Blocked;

0 commit comments

Comments
 (0)