| | 1 | | @namespace Syki.Front.Pages.Cross |
| | 2 | |
|
| | 3 | | @page "/login-mfa" |
| | 4 | |
|
| | 5 | | <SykiPageTitle Title="Login MFA" /> |
| | 6 | |
|
| | 7 | | <MudContainer Class="mt-4 mb-8" MaxWidth="MaxWidth.ExtraSmall"> |
| | 8 | | <MudOverlay @bind-Visible="@_loading" LightBackground="true" Absolute="false"> |
| | 9 | | <MudProgressCircular Color="Color.Info" Indeterminate="true" Size="Size.Large" /> |
| | 10 | | </MudOverlay> |
| | 11 | | <style>input { text-align: center; font-size: 24px !important; letter-spacing: 3px !important; }</style> |
| | 12 | | <MudCard Class="px-4 pt-8" Style="height: 460px"> |
| | 13 | | <MudCardContent> |
| | 14 | | <MudStack AlignItems="AlignItems.Center"> |
| | 15 | | <MudAlert NoIcon="true" Class="px-4 mb-4" Severity="Severity.Info" Variant="Variant.Text" ContentAlignme |
| | 16 | | <MudStack Row="true" Justify="Justify.SpaceAround"> |
| | 17 | | <MudText>Insira o código gerado pelo app Google Authenticator para realizar o login</MudText> |
| | 18 | | </MudStack> |
| | 19 | | </MudAlert> |
| | 20 | | <MudForm> |
| | 21 | | <style> |
| | 22 | | .align-center input{ |
| | 23 | | text-align: center; |
| | 24 | | } |
| | 25 | | </style> |
| | 26 | | <MudNumericField |
| | 27 | | T="int?" |
| | 28 | | Immediate="true" |
| | 29 | | OnlyValidateIfDirty="true" |
| | 30 | | ReadOnly="@_loading" |
| | 31 | | Style="width: 200px;" |
| | 32 | | Value="@_code" |
| | 33 | | ValueChanged="@HandleCodeChanged" |
| | 34 | | Variant="Variant.Outlined" |
| | 35 | | HideSpinButtons="true" |
| | 36 | | AutoFocus="true" |
| | 37 | | Typo="Typo.h6" |
| | 38 | | Class="mt-8" |
| | 39 | | Margin="Margin.Dense" |
| | 40 | | Max="999999" |
| | 41 | | MaxLength="6" |
| | 42 | | Min="0" |
| | 43 | | /> |
| | 44 | | </MudForm> |
| 0 | 45 | | @if (_showCodeFeedback) |
| | 46 | | { |
| | 47 | | <MudAlert Class="mt-4" Severity="Severity.Error" Variant="Variant.Text"> |
| | 48 | | <MudStack Row="true" Justify="Justify.SpaceAround"> |
| | 49 | | <MudText>Código inválido</MudText> |
| | 50 | | </MudStack> |
| | 51 | | </MudAlert> |
| | 52 | | } |
| | 53 | | </MudStack> |
| | 54 | | </MudCardContent> |
| | 55 | | </MudCard> |
| | 56 | | </MudContainer> |
| | 57 | |
|
| | 58 | | @inject LoginMfaClient Client |
| | 59 | | @inject NavigationManager Nav |
| | 60 | |
|
| | 61 | | @code |
| | 62 | | { |
| | 63 | | private int? _code; |
| | 64 | | private bool _loading; |
| | 65 | | private bool _showCodeFeedback; |
| | 66 | |
|
| | 67 | | private async Task HandleCodeChanged(int? newValue) |
| | 68 | | { |
| 0 | 69 | | _showCodeFeedback = false; |
| 0 | 70 | | _code = newValue; |
| | 71 | |
|
| 0 | 72 | | if (_code.ToString().Length == 6) |
| | 73 | | { |
| 0 | 74 | | _loading = true; |
| 0 | 75 | | var result = await Client.Login(_code.ToString()!); |
| | 76 | |
|
| 0 | 77 | | if (result.AccessToken != null) |
| | 78 | | { |
| 0 | 79 | | Nav.NavigateTo("/"); |
| | 80 | | } |
| | 81 | |
|
| 0 | 82 | | _showCodeFeedback = true; |
| 0 | 83 | | _loading = false; |
| | 84 | | } |
| 0 | 85 | | } |
| | 86 | | } |