Update MudBlazor integration, improve captcha handling, and upgrade project dependencies
This commit is contained in:
@@ -1,12 +1,63 @@
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">@GetDialogTitle()</MudText>
|
||||
@if (InlineMode)
|
||||
{
|
||||
@* Inline rendering without MudDialog wrapper *@
|
||||
<MudStack Spacing="2">
|
||||
<MudText Typo="Typo.h5" Align="Align.Center">@GetDialogTitle()</MudText>
|
||||
@PhoneOrVerifyContent()
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">@GetDialogTitle()</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@PhoneOrVerifyContent()
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
@if (!HideCancelButton)
|
||||
{
|
||||
<MudButton Variant="Variant.Text"
|
||||
OnClick="Cancel"
|
||||
Disabled="_isBusy">لغو</MudButton>
|
||||
}
|
||||
@if (_currentStep == AuthStep.Phone)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="SendOtpAsync"
|
||||
Disabled="_isBusy"
|
||||
FullWidth="true">
|
||||
ارسال رمز پویا
|
||||
</MudButton>
|
||||
}
|
||||
else if (_currentStep == AuthStep.Verify)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="VerifyOtpAsync"
|
||||
Disabled="_isBusy || IsVerificationLocked"
|
||||
FullWidth="true">
|
||||
تأیید و ورود
|
||||
</MudButton>
|
||||
}
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
}
|
||||
|
||||
@code {
|
||||
private RenderFragment PhoneOrVerifyContent() => __builder =>
|
||||
{
|
||||
if (_currentStep == AuthStep.Phone)
|
||||
{
|
||||
<!-- Phone Step -->
|
||||
<MudText Typo="Typo.body2" Class="mb-4" Align="Align.Center">لطفاً شماره موبایل خود را وارد کنید تا رمز پویا ارسال شود.</MudText>
|
||||
// Phone Step
|
||||
__builder.OpenComponent(0, typeof(MudText));
|
||||
__builder.AddAttribute(1, "Typo", Typo.body2);
|
||||
__builder.AddAttribute(2, "Class", "mb-4");
|
||||
__builder.AddAttribute(3, "Align", Align.Center);
|
||||
__builder.AddContent(4, "لطفاً شماره موبایل خود را وارد کنید تا رمز پویا ارسال شود.");
|
||||
__builder.CloseComponent();
|
||||
|
||||
<MudForm @ref="_phoneForm" Model="_phoneRequest" Validation="@(_phoneRequestValidator.ValidateValue)">
|
||||
<MudTextField @bind-Value="_phoneRequest.Mobile"
|
||||
@@ -21,6 +72,21 @@
|
||||
HelperText="مثال: 09121234567"
|
||||
Class="mb-2" />
|
||||
|
||||
@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>
|
||||
</MudPaper>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Refresh" Disabled="_isBusy" OnClick="GenerateCaptcha">
|
||||
تازهسازی کد
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
<MudTextField Label="کد کپچا" Placeholder="کد نمایش داده شده" Immediate="true"
|
||||
Variant="Variant.Outlined" @bind-Value="_captchaInput" Required="true"
|
||||
RequiredError="لطفاً کد کپچا را وارد کنید." />
|
||||
}
|
||||
|
||||
<MudCheckBox T="bool"
|
||||
Label="شرایط و قوانین را میپذیرم"
|
||||
Class="mb-1" />
|
||||
@@ -33,7 +99,7 @@
|
||||
}
|
||||
else if (_currentStep == AuthStep.Verify)
|
||||
{
|
||||
<!-- Verify Step -->
|
||||
// Verify Step
|
||||
<MudText Typo="Typo.body2" Class="mb-4" Align="Align.Center">رمز پویا شش رقمی ارسال شده به @_phoneNumber را وارد کنید.</MudText>
|
||||
|
||||
<MudForm @ref="_verifyForm" Model="_verifyRequest" Validation="@(_verifyRequestValidator.ValidateValue)">
|
||||
@@ -50,85 +116,28 @@
|
||||
Class="mb-2"
|
||||
MaxLength="6" />
|
||||
|
||||
@* <MudText Typo="Typo.body1" Align="Align.Center" Class="mb-2">
|
||||
تلاش باقیمانده: @_attemptsLeft از @MaxVerificationAttempts
|
||||
</MudText> *@
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(_errorMessage))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error"
|
||||
Dense="true"
|
||||
Elevation="0"
|
||||
Class="mb-2">
|
||||
@(_errorMessage)
|
||||
</MudAlert>
|
||||
<MudAlert Severity="Severity.Error" Dense="true" Elevation="0" Class="mb-2">@(_errorMessage)</MudAlert>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(_infoMessage))
|
||||
{
|
||||
<MudAlert Severity="Severity.Success"
|
||||
Dense="true"
|
||||
Elevation="0"
|
||||
Class="mb-2">
|
||||
@(_infoMessage)
|
||||
</MudAlert>
|
||||
<MudAlert Severity="Severity.Success" Dense="true" Elevation="0" Class="mb-2">@(_infoMessage)</MudAlert>
|
||||
}
|
||||
|
||||
<MudStack Spacing="2">
|
||||
<MudButton Variant="Variant.Text"
|
||||
Color="Color.Secondary"
|
||||
Disabled="_isBusy"
|
||||
OnClick="ChangePhoneAsync">
|
||||
تغییر شماره
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Secondary" Disabled="_isBusy" OnClick="ChangePhoneAsync">تغییر شماره</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudDivider Class="my-2" />
|
||||
|
||||
@if (_resendRemaining > 0)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Align="Align.Center" Class="mud-text-secondary">
|
||||
امکان ارسال مجدد تا @_resendRemaining ثانیه دیگر
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Align="Align.Center" Class="mud-text-secondary">امکان ارسال مجدد تا @_resendRemaining ثانیه دیگر</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Text"
|
||||
Color="Color.Primary"
|
||||
Disabled="_isBusy"
|
||||
OnClick="ResendOtpAsync">
|
||||
ارسال مجدد رمز پویا
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" Disabled="_isBusy" OnClick="ResendOtpAsync">ارسال مجدد رمز پویا</MudButton>
|
||||
}
|
||||
</MudForm>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
@if (!HideCancelButton)
|
||||
{
|
||||
<MudButton Variant="Variant.Text"
|
||||
OnClick="Cancel"
|
||||
Disabled="_isBusy">لغو</MudButton>
|
||||
}
|
||||
@if (_currentStep == AuthStep.Phone)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="SendOtpAsync"
|
||||
Disabled="_isBusy"
|
||||
FullWidth="true">
|
||||
ارسال رمز پویا
|
||||
</MudButton>
|
||||
}
|
||||
else if (_currentStep == AuthStep.Verify)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="VerifyOtpAsync"
|
||||
Disabled="_isBusy || IsVerificationLocked"
|
||||
FullWidth="true">
|
||||
تأیید و ورود
|
||||
</MudButton>
|
||||
}
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user