Skip to content

Commit 1556615

Browse files
committed
[Docs] .NET Fix LoginWithOtp Example (#5843)
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 -->
1 parent 7293dfa commit 1556615

File tree

1 file changed

+4
-19
lines changed
  • apps/portal/src/app/dotnet/wallets/providers/in-app-wallet

1 file changed

+4
-19
lines changed

apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var isConnected = await wallet.IsConnected();
4646
4747
// Email & Phone (OTP)
4848
await wallet.SendOTP(); // and fetch the otp
49-
var (address, canRetry) = await wallet.LoginWithOtp("userEnteredOTP");
49+
var address = await wallet.LoginWithOtp("userEnteredOTP"); // try catch and retry if needed
5050
5151
// Socials (OAuth)
5252
var address = await wallet.LoginWithOauth(
@@ -121,12 +121,8 @@ await wallet.SendOTP();
121121
**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.
122122

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

132128
## Example
@@ -143,18 +139,7 @@ if (!await inAppWallet.IsConnected())
143139
await inAppWallet.SendOTP();
144140
Console.WriteLine("Please submit the OTP.");
145141
var otp = Console.ReadLine();
146-
(var inAppWalletAddress, var canRetry) = await inAppWallet.LoginWithOtp(otp);
147-
if (inAppWalletAddress == null && canRetry)
148-
{
149-
Console.WriteLine("Please submit the OTP again.");
150-
otp = Console.ReadLine();
151-
(inAppWalletAddress, _) = await inAppWallet.LoginWithOtp(otp);
152-
}
153-
if (inAppWalletAddress == null)
154-
{
155-
Console.WriteLine("OTP login failed. Please try again.");
156-
return;
157-
}
142+
var inAppWalletAddress = await inAppWallet.LoginWithOtp(otp); // try catch and retry if needed
158143
}
159144

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

0 commit comments

Comments
 (0)