Refactor AuthDialog to remove captcha handling and improve dialog display options
This commit is contained in:
@@ -11,7 +11,7 @@ namespace FrontOffice.Main.Shared;
|
||||
public partial class AuthDialog : IDisposable
|
||||
{
|
||||
[Parameter] public bool HideCancelButton { get; set; }
|
||||
[Parameter] public bool EnableCaptcha { get; set; }
|
||||
// [Parameter] public bool EnableCaptcha { get; set; }
|
||||
[Parameter] public bool InlineMode { get; set; }
|
||||
|
||||
public enum AuthStep { Phone, Verify }
|
||||
@@ -48,7 +48,8 @@ public partial class AuthDialog : IDisposable
|
||||
[Inject] private ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
[Inject] private UserContract.UserContractClient UserClient { get; set; } = default!;
|
||||
|
||||
[CascadingParameter] private IDialogReference? MudDialog { get; set; }
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter] public EventCallback OnLoginSuccess { get; set; }
|
||||
|
||||
@@ -59,16 +60,17 @@ public partial class AuthDialog : IDisposable
|
||||
_phoneRequest.Purpose = OtpPurpose;
|
||||
_verifyRequest.Purpose = OtpPurpose;
|
||||
|
||||
if (EnableCaptcha)
|
||||
{
|
||||
// if (EnableCaptcha)
|
||||
// {
|
||||
GenerateCaptcha();
|
||||
}
|
||||
// }
|
||||
|
||||
var storedPhone = await LocalStorage.GetItemAsync<string>(PhoneStorageKey);
|
||||
if (!string.IsNullOrWhiteSpace(storedPhone))
|
||||
{
|
||||
_phoneRequest.Mobile = storedPhone;
|
||||
}
|
||||
await LocalStorage.RemoveItemAsync(TokenStorageKey);
|
||||
}
|
||||
|
||||
private void GenerateCaptcha()
|
||||
@@ -87,14 +89,14 @@ public partial class AuthDialog : IDisposable
|
||||
if (!_phoneForm.IsValid)
|
||||
return;
|
||||
|
||||
if (EnableCaptcha)
|
||||
{
|
||||
// if (EnableCaptcha)
|
||||
// {
|
||||
if (string.IsNullOrWhiteSpace(_captchaInput) || !string.Equals(_captchaInput.Trim(), _captchaCode, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_errorMessage = "کد کپچا صحیح نیست.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
_isBusy = true;
|
||||
_operationCts?.Cancel();
|
||||
@@ -368,7 +370,7 @@ public partial class AuthDialog : IDisposable
|
||||
_resendTimer?.Dispose();
|
||||
_resendTimer = null;
|
||||
_resendRemaining = 0;
|
||||
if (EnableCaptcha)
|
||||
// if (EnableCaptcha)
|
||||
GenerateCaptcha();
|
||||
}
|
||||
|
||||
@@ -420,7 +422,7 @@ public partial class AuthDialog : IDisposable
|
||||
private void Cancel()
|
||||
{
|
||||
if (!InlineMode)
|
||||
MudDialog?.Close(DialogResult.Cancel());
|
||||
MudDialog?.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user