LoginPages.razor.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using Microsoft.AspNetCore.Components.Authorization;
  4. using System.Net.Http;
  5. using System.Net.Http.Json;
  6. using wispro.sp.share.webViewObject;
  7. using wispro.sp.web.Services;
  8. using System.IdentityModel.Tokens.Jwt;
  9. using Microsoft.IdentityModel.Tokens;
  10. using System.Linq;
  11. using System.Security.Claims;
  12. using Blazored.LocalStorage;
  13. using System;
  14. using System.Text.Json;
  15. namespace wispro.sp.web.Pages
  16. {
  17. public partial class LoginPages
  18. {
  19. [Inject] public HttpClient Http { get; set; }
  20. [Inject] public MessageService MsgSvr { get; set; }
  21. //[Inject] public AuthenticationStateProvider AuthProvider { get; set; }
  22. [Inject] public IUserService _UserService { get; set; }
  23. [Inject] public IAuthService authService { get; set; }
  24. [Inject] public NavigationManager navigation { get; set; }
  25. loginDto model = new loginDto();
  26. bool isLoading;
  27. async void OnLogin()
  28. {
  29. isLoading = true;
  30. bool result = await authService.LoginAsync(model);
  31. if (result)
  32. {
  33. if (model.Password == "12345678")
  34. {
  35. navigation.NavigateTo("/ChangePassword/true");
  36. }
  37. else
  38. {
  39. navigation.NavigateTo("/Home");
  40. }
  41. }
  42. else
  43. {
  44. _ = MsgSvr.Error($"用户名或密码错误");
  45. }
  46. isLoading = false;
  47. }
  48. }
  49. }