Refactor AuthDialog to remove captcha handling and improve dialog display options
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudDialog>
|
||||
<MudDialog >
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">@GetDialogTitle()</MudText>
|
||||
</TitleContent>
|
||||
@@ -72,8 +72,8 @@ else
|
||||
HelperText="مثال: 09121234567"
|
||||
Class="mb-2" />
|
||||
|
||||
@if (EnableCaptcha)
|
||||
{
|
||||
@* @if (EnableCaptcha) *@
|
||||
@* { *@
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2" Class="mt-2 mb-2">
|
||||
<MudPaper Elevation="1" Class="captcha-box d-flex align-center justify-center" Style="min-width:100px;min-height:48px;">
|
||||
<MudText Typo="Typo.h5">@_captchaCode</MudText>
|
||||
@@ -85,7 +85,7 @@ else
|
||||
<MudTextField Label="کد کپچا" Placeholder="کد نمایش داده شده" Immediate="true"
|
||||
Variant="Variant.Outlined" @bind-Value="_captchaInput" Required="true"
|
||||
RequiredError="لطفاً کد کپچا را وارد کنید." />
|
||||
}
|
||||
@* } *@
|
||||
|
||||
<MudCheckBox T="bool"
|
||||
Label="شرایط و قوانین را میپذیرم"
|
||||
|
||||
@@ -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