You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.9 KiB

  1. @page "/login"
  2. @using BootStrapComponents
  3. @using Components
  4. @using Models.Identity
  5. @layout LayoutWithoutMenu
  6. <style>
  7. form {
  8. min-height: 300px;
  9. }
  10. </style>
  11. <div class="login text-center p-5">
  12. <div class="logo">
  13. <img src="assets/img/logo.svg" alt="">
  14. </div>
  15. <EditForm Model="@LoginModel" OnValidSubmit="Submit">
  16. <DataAnnotationsValidator />
  17. <div class="d-flex flex-column">
  18. <input type="email" @bind="LoginModel.Username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter Email">
  19. <input type="password" @bind="LoginModel.Password" class="form-control mt-2" id="exampleInputPassword1" placeholder="Password">
  20. <a href="" class="btn text-right">Forgot Password?</a>
  21. <button class="btn btn-primary mt-2">
  22. @(Loading ? "Wait..." : "Login")
  23. </button>
  24. <ValidationSummary></ValidationSummary>
  25. </div>
  26. </EditForm>
  27. <div class="d-flex flex-column">
  28. <div class="title_line">Or Login with</div>
  29. <div class="d-flex social_login">
  30. <a href="" class="btn"><img src="assets/img/google_ic.svg"></a>
  31. </div>
  32. </div>
  33. <div>
  34. Don’t have an account? <a href="/Signup" class="bold text-secondary">Register Now</a>
  35. </div>
  36. </div>
  37. @code {
  38. protected LoginModel LoginModel { get; set; } = new();
  39. protected bool Loading { set; get; }
  40. protected async Task Submit()
  41. {
  42. Loading = true;
  43. StateHasChanged();
  44. var response = await _userUtils.LoginWithPasswordRequest(LoginModel);
  45. Loading = false;
  46. if (response.IsSuccessStatusCode)
  47. {
  48. var result = await response.Content.ReadFromJsonAsync<Models.Identity.PlainToken>();
  49. await LocalStorage.SetItemAsync(Statics.LoginTokenKey, result.AccessToken);
  50. NavManager.NavigateTo("/dashboard");
  51. }
  52. }
  53. }