Enhance authentication flow; add user registration completion check and update contract acceptance process
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
@@ -47,6 +48,7 @@ public partial class AuthDialog : IDisposable
|
||||
|
||||
[Inject] private ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
[Inject] private UserContract.UserContractClient UserClient { get; set; } = default!;
|
||||
[Inject] private AuthService AuthService { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; }
|
||||
@@ -230,6 +232,17 @@ public partial class AuthDialog : IDisposable
|
||||
{
|
||||
MudDialog?.Close();
|
||||
}
|
||||
if (await AuthService.IsAuthenticatedAsync())
|
||||
{
|
||||
if (!(await AuthService.IsCompleteRegisterAsync()))
|
||||
{
|
||||
Navigation.NavigateTo(RouteConstants.Registration.Wizard);
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo(RouteConstants.Profile.Index);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
@if (_isAuthenticated)
|
||||
{
|
||||
<MudMenu Icon="@Icons.Material.Filled.Person" Color="Color.Inherit" Size="Size.Medium">
|
||||
<MudMenuItem OnClick="NavigateToProfile">پروفایل</MudMenuItem>
|
||||
<MudMenuItem OnClick="NavigateToProfile" Disabled="@(AuthService.IsCompleteRegister())">پروفایل</MudMenuItem>
|
||||
<MudDivider />
|
||||
<MudMenuItem OnClick="Logout">خروج از حساب</MudMenuItem>
|
||||
</MudMenu>
|
||||
|
||||
@@ -50,7 +50,9 @@ public partial class MainLayout
|
||||
{
|
||||
Snackbar.Add(GlobalConstants.SuccessMsg, Severity.Success);
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
Navigation.NavigateTo(RouteConstants.Main.MainPage);
|
||||
}
|
||||
|
||||
private void NavigateToProfile()
|
||||
|
||||
35
src/FrontOffice.Main/Shared/SimpleOtpDialog.razor
Normal file
35
src/FrontOffice.Main/Shared/SimpleOtpDialog.razor
Normal file
@@ -0,0 +1,35 @@
|
||||
@using MudBlazor
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudText Typo="Typo.body1" Class="mb-3">@ContentText</MudText>
|
||||
<MudTextField @bind-Value="OtpCode"
|
||||
Label="کد تأیید"
|
||||
Variant="Variant.Outlined"
|
||||
InputType="InputType.Text"
|
||||
MaxLength="6"
|
||||
Immediate="true"
|
||||
Required="true"
|
||||
RequiredError="کد تایید الزامی است"
|
||||
FullWidth="true" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="Cancel">انصراف</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="Submit" Disabled="string.IsNullOrWhiteSpace(OtpCode)">@ButtonText</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter] public string ContentText { get; set; } = "";
|
||||
[Parameter] public string ButtonText { get; set; } = "تأیید";
|
||||
|
||||
private string? OtpCode { get; set; }
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
private void Submit() => MudDialog.Close(DialogResult.Ok(OtpCode));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user