| | 1 | | @namespace Syki.Front.Features.Cross.GetMfaKey |
| | 2 | |
|
| | 3 | | <MudPaper> |
| | 4 | | <MudCard Class="px-4 py-0" Elevation="0"> |
| | 5 | | <MudCardContent> |
| | 6 | | <MudStack AlignItems="AlignItems.Center"> |
| | 7 | | <MudAlert NoIcon="true" Severity="Severity.Info" Variant="Variant.Text"> |
| | 8 | | <MudStack Row="true" Justify="Justify.SpaceAround"> |
| | 9 | | <MudText>Utilize o app Google Authenticator para ler o QR-Code</MudText> |
| | 10 | | </MudStack> |
| | 11 | | </MudAlert> |
| 0 | 12 | | @if (_qrCodeLoading) |
| | 13 | | { |
| | 14 | | <MudContainer MaxWidth="MaxWidth.False" Style="max-width: 380px" Class="px-0 d-flex align-center jus |
| | 15 | | <MudProgressCircular Class="py-10" Style="width: 50%; height: 50%" Color="Color.Dark" Indetermin |
| | 16 | | </MudContainer> |
| | 17 | | } |
| | 18 | | else |
| | 19 | | { |
| | 20 | | <MudContainer MaxWidth="MaxWidth.False" Style="max-width: 380px" Class="px-0"> |
| | 21 | | <MudImage Src="@(GetQrCodeImageSrc())" Fluid="true" Elevation="25" Class="rounded-lg"/> |
| | 22 | | </MudContainer> |
| | 23 | | <MudContainer MaxWidth="MaxWidth.False" Style="max-width: 380px" Class="px-0"> |
| | 24 | | <SykiTextField Value="@_key" CopyAdornment="true" ReadOnly="true" /> |
| | 25 | | </MudContainer> |
| | 26 | | } |
| | 27 | | </MudStack> |
| | 28 | | </MudCardContent> |
| | 29 | | </MudCard> |
| | 30 | | </MudPaper> |
| | 31 | |
|
| | 32 | | @inject GetMfaKeyClient Client |
| | 33 | |
|
| | 34 | | @code |
| | 35 | | { |
| | 36 | | [CascadingParameter] |
| 0 | 37 | | public Task<AuthenticationState> AuthState { get; set; } |
| | 38 | |
|
| | 39 | | private string _key; |
| | 40 | | private bool _qrCodeLoading; |
| | 41 | | private Byte[] _codeBytes; |
| | 42 | |
|
| | 43 | | protected override async Task OnInitializedAsync() |
| | 44 | | { |
| 0 | 45 | | _qrCodeLoading = true; |
| | 46 | |
|
| 0 | 47 | | var result = await Client.Get(); |
| 0 | 48 | | var email = await GetUserEmail(); |
| 0 | 49 | | _key = result.Key; |
| 0 | 50 | | _codeBytes = _key.GenerateQrCodeBytes(email); |
| | 51 | |
|
| 0 | 52 | | _qrCodeLoading = false; |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | private async Task<string> GetUserEmail() |
| | 56 | | { |
| 0 | 57 | | var state = await AuthState; |
| | 58 | |
|
| 0 | 59 | | var claim = state.User.FindFirst("email"); |
| 0 | 60 | | if (claim != null) |
| | 61 | | { |
| 0 | 62 | | return claim.Value; |
| | 63 | | } |
| | 64 | |
|
| 0 | 65 | | return ""; |
| 0 | 66 | | } |
| | 67 | |
|
| | 68 | | private string GetQrCodeImageSrc() |
| | 69 | | { |
| 0 | 70 | | if (_codeBytes == null) return ""; |
| 0 | 71 | | return string.Format("data:image/png;base64,{0}", Convert.ToBase64String(_codeBytes)); |
| | 72 | | } |
| | 73 | | } |