Skip to content

Commit 5e8798f

Browse files
committed
fixup! feat(oauth): add flow for reciprocating a login using a QR code generated on the existing device
Avoid unwraps in examples Signed-off-by: Johannes Marbach <[email protected]>
1 parent 884f2de commit 5e8798f

File tree

1 file changed

+10
-8
lines changed
  • crates/matrix-sdk/src/authentication/oauth

1 file changed

+10
-8
lines changed

crates/matrix-sdk/src/authentication/oauth/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ impl<'a> LoginWithQrCodeBuilder<'a> {
14561456
/// ruma::serde::Raw,
14571457
/// Client,
14581458
/// };
1459-
/// use std::io::stdin;
1459+
/// use std::{error::Error, io::stdin};
14601460
/// # fn client_metadata() -> Raw<ClientMetadata> { unimplemented!() }
14611461
/// # _ = async {
14621462
/// // Build the client as usual.
@@ -1487,16 +1487,17 @@ impl<'a> LoginWithQrCodeBuilder<'a> {
14871487
/// LoginProgress::EstablishingSecureChannel(GeneratedQrProgress::QrScanned(cctx)) => {
14881488
/// println!("Please enter the code displayed on your other device");
14891489
/// let mut s = String::new();
1490-
/// stdin().read_line(&mut s).unwrap();
1491-
/// let check_code = s.trim().parse::<u8>().unwrap();
1492-
/// cctx.send(check_code).await.unwrap()
1490+
/// stdin().read_line(&mut s)?;
1491+
/// let check_code = s.trim().parse::<u8>()?;
1492+
/// cctx.send(check_code).await?
14931493
/// }
14941494
/// LoginProgress::WaitingForToken { user_code } => {
14951495
/// println!("Please use your other device to confirm the log in {user_code}")
14961496
/// },
14971497
/// LoginProgress::Done => break,
14981498
/// }
14991499
/// }
1500+
/// Ok::<(), Box<dyn Error + Send + Sync>>(())
15001501
/// });
15011502
///
15021503
/// // Now run the future to complete the login.
@@ -1534,7 +1535,7 @@ impl<'a> GrantLoginWithQrCodeBuilder<'a> {
15341535
/// qrcode::{GeneratedQrProgress, GrantLoginProgress}
15351536
/// }
15361537
/// };
1537-
/// use std::io::stdin;
1538+
/// use std::{error::Error, io::stdin};
15381539
/// # _ = async {
15391540
/// // Build the client as usual.
15401541
/// let client = Client::builder()
@@ -1563,16 +1564,17 @@ impl<'a> GrantLoginWithQrCodeBuilder<'a> {
15631564
/// GrantLoginProgress::EstablishingSecureChannel(GeneratedQrProgress::QrScanned(checkcode_sender)) => {
15641565
/// println!("Please enter the code displayed on your other device");
15651566
/// let mut s = String::new();
1566-
/// stdin().read_line(&mut s).unwrap();
1567-
/// let check_code = s.trim().parse::<u8>().unwrap();
1568-
/// checkcode_sender.send(check_code).await;
1567+
/// stdin().read_line(&mut s)?;
1568+
/// let check_code = s.trim().parse::<u8>()?;
1569+
/// checkcode_sender.send(check_code).await?;
15691570
/// }
15701571
/// GrantLoginProgress::WaitingForAuth { verification_uri } => {
15711572
/// println!("Please open {verification_uri} to confirm the new login")
15721573
/// },
15731574
/// GrantLoginProgress::Done => break,
15741575
/// }
15751576
/// }
1577+
/// Ok::<(), Box<dyn Error + Send + Sync>>(())
15761578
/// });
15771579
///
15781580
/// // Now run the future to grant the login.

0 commit comments

Comments
 (0)