Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //_imports.razor
- @using System.Net.Http
- @using System.Net.Http.Json
- @using Microsoft.AspNetCore.Components.Authorization
- @using Microsoft.AspNetCore.Components.Forms
- @using Microsoft.AspNetCore.Components.Routing
- @using Microsoft.AspNetCore.Components.Web
- @using Microsoft.AspNetCore.Components.Web.Virtualization
- @using Microsoft.JSInterop
- @using BlazorAppIdentityDotNet8
- @using BlazorAppIdentityDotNet8.Client
- @using BlazorAppIdentityDotNet8.Components
- @using BlazorAppIdentityDotNet8.Data
- @using BlazorAppIdentityDotNet8.Data.Model
- @using BlazorAppIdentityDotNet8.Components.Pages.Tickets.Input
- @using BlazorAppIdentityDotNet8.Service.IRepo
- @using System.Text.RegularExpressions
- @using QRCoder;
- @using System.Drawing;
- @using System.IO;
- @using System.Net
- @using System.Security.Claims
- @using System.ComponentModel.DataAnnotations
- @using System.Text
- @using Microsoft.AspNetCore.Authentication
- @using Microsoft.AspNetCore.Identity
- @using Microsoft.AspNetCore.WebUtilities
- @using BlazorAppIdentityDotNet8.Identity
- //Login.razor
- public async Task LoginUser()
- {
- try
- {
- var result = await SignInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);
- if (result != null)
- enable = true;
- if (result.Succeeded)
- {
- Logger.LogInformation("User logged in.");
- //Throw the error
- RedirectManager.RedirectTo(ReturnUrl);
- }
- else if (result.RequiresTwoFactor)
- {
- //Throw the error
- RedirectManager.RedirectTo(
- "/Account/LoginWith2fa",
- new() { ["ReturnUrl"] = ReturnUrl, ["RememberMe"] = Input.RememberMe });
- }
- else if (result.IsLockedOut)
- {
- Logger.LogWarning("User account locked out.");
- //Throw the error
- RedirectManager.RedirectTo("/Account/Lockout");
- }
- else
- {
- errorMessage = "Error: Invalid login attempt.";
- }
- }
- catch (NavigationException ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment