1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using AntDesign;
- using Microsoft.AspNetCore.Components;
- using Microsoft.AspNetCore.Components.Authorization;
- using System.Net.Http;
- using System.Net.Http.Json;
- using wispro.sp.share.webViewObject;
- using wispro.sp.web.Services;
- using System.IdentityModel.Tokens.Jwt;
- using Microsoft.IdentityModel.Tokens;
- using System.Linq;
- using System.Security.Claims;
- using Blazored.LocalStorage;
- using System;
- using System.Text.Json;
- using wispro.sp.entity;
- using wispro.sp.share;
- using Microsoft.AspNetCore.Components.Web;
- namespace wispro.sp.web.Pages
- {
- public partial class LoginPages
- {
- [Inject] public HttpClient Http { get; set; }
- [Inject] public MessageService MsgSvr { get; set; }
- //[Inject] public AuthenticationStateProvider AuthProvider { get; set; }
- [Inject] public IUserService _UserService { get; set; }
- [Inject] public IAuthService authService { get; set; }
- [Inject] public NavigationManager navigation { get; set; }
- loginDto model = new loginDto();
- bool isLoading;
- async void OnLogin()
- {
- isLoading = true;
-
- bool result = await authService.LoginAsync(model);
-
- if (result)
- {
- if (model.Password == "12345678")
- {
- navigation.NavigateTo("/ChangePassword/true");
- }
- else
- {
- navigation.NavigateTo("/Home");
- }
- }
- else
- {
- _ = MsgSvr.Error($"用户名或密码错误");
-
- }
-
- isLoading = false;
- }
- bool ShowResetPassword = false;
- private Staff EditingStaff = new Staff();
- void ResetPassword()
- {
- ShowResetPassword = true;
- EditingStaff = new Staff();
- }
- private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e)
- {
- if(String.IsNullOrEmpty(EditingStaff.Account ) || string.IsNullOrEmpty(EditingStaff.Mail)){
- await MsgSvr.Success("请输入账号名称和邮箱!");
- return;
- }
- var data = await authService.ResetPassword(EditingStaff.Account,EditingStaff.Mail);
- if (data.Success)
- {
- await MsgSvr.Success("重置成功,新密码已发您邮箱!");
- ShowResetPassword = false;
- }
- else
- {
- await MsgSvr.Error($"请求发生错误 {data.ErrorMessage}");
- }
- }
- private void HandleCancel(MouseEventArgs e)
- {
- ShowResetPassword = false;
- }
- }
- }
|