Skip to content

Commit

Permalink
[Docs] .NET Fix LoginWithOtp Example (#5843)
Browse files Browse the repository at this point in the history
Closes TOOL-2863

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on simplifying the OTP login process in the `InAppWallet` by removing the `canRetry` variable and related conditional logic, providing a more straightforward approach for handling OTP submissions.

### Detailed summary
- Removed the `canRetry` variable from the `LoginWithOtp` method calls.
- Simplified the OTP login logic by eliminating the retry checks.
- Added comments to indicate where to implement error handling and retries if needed.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
0xFirekeeper committed Dec 27, 2024
1 parent 7293dfa commit 1556615
Showing 1 changed file with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var isConnected = await wallet.IsConnected();
// Email & Phone (OTP)
await wallet.SendOTP(); // and fetch the otp
var (address, canRetry) = await wallet.LoginWithOtp("userEnteredOTP");
var address = await wallet.LoginWithOtp("userEnteredOTP"); // try catch and retry if needed
// Socials (OAuth)
var address = await wallet.LoginWithOauth(
Expand Down Expand Up @@ -121,12 +121,8 @@ await wallet.SendOTP();
**Submit OTP:** Once the user receives the OTP, they submit it back to the application, which then calls LoginWithOtp on the InAppWallet instance to verify the OTP and complete the login process.

```csharp
var (address, canRetry) = await wallet.LoginWithOtp("userEnteredOTP");
if (address != null) {
// Login successful
} else if (canRetry) {
// Ask user to retry entering OTP
}
var address = await wallet.LoginWithOtp("userEnteredOTP");
// If this fails, feel free to catch and take in another OTP and retry the login process
```

## Example
Expand All @@ -143,18 +139,7 @@ if (!await inAppWallet.IsConnected())
await inAppWallet.SendOTP();
Console.WriteLine("Please submit the OTP.");
var otp = Console.ReadLine();
(var inAppWalletAddress, var canRetry) = await inAppWallet.LoginWithOtp(otp);
if (inAppWalletAddress == null && canRetry)
{
Console.WriteLine("Please submit the OTP again.");
otp = Console.ReadLine();
(inAppWalletAddress, _) = await inAppWallet.LoginWithOtp(otp);
}
if (inAppWalletAddress == null)
{
Console.WriteLine("OTP login failed. Please try again.");
return;
}
var inAppWalletAddress = await inAppWallet.LoginWithOtp(otp); // try catch and retry if needed
}

Console.WriteLine($"InAppWallet address: {await inAppWallet.GetAddress()}");
Expand Down

0 comments on commit 1556615

Please sign in to comment.