public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] AuthsDto dto) { //Todo:获取用户信息 //var user = new UserDto //{ // Id = "111id", // UserName = "******", // Role = Guid.Empty, // Email = "*****@*****.**", // Phone = "13912345678", //}; var users = await _accountRepository.GetCurrentUserAsync(dto.Account, dto.Password); UserDto user = null; if (users != null) { user = new UserDto() { Id = users.Id.ToString(), UserName = users.Name, Email = "*****@*****.**", Role = Guid.Empty, Phone = "13912345678", } } ; if (user == null) { return(Ok(new JwtResponseDto { Access = "无权访问", Type = "Bearer", Profile = new Profile { Name = dto.Account, Auths = 0, Expires = 0 } })); } var jwt = await _jwtApp.RefreshAsync(dto.Token, user); return(Ok(new JwtResponseDto { Access = jwt.Token, Type = "Bearer", Profile = new Profile { Name = user.UserName, Auths = jwt.Success ? jwt.Auths : 0, Expires = jwt.Success ? jwt.Expires : 0 } })); } #endregion }
public async Task <IActionResult> LoginAsync([FromBody] AuthsDto dto) { // 获取账户信息 var users = await _accountRepository.GetCurrentUserAsync(dto.Account, dto.Password); UserDto user = null; if (users != null) { user = new UserDto() { Id = users.Id.ToString(), UserName = users.Name, Email = "*****@*****.**", Role = Guid.Empty, Phone = "13912345678", } } ; if (user == null) { return(Ok(new JwtResponseDto { Access = "无权访问", Type = "Bearer", Profile = new Profile { Name = dto.Account, Auths = 0, Expires = 0 } })); } var jwt = _jwtApp.Create(user); return(Ok(new JwtResponseDto { Access = jwt.Token, Type = "Bearer", Profile = new Profile { Name = user.UserName, Auths = jwt.Auths, Expires = jwt.Expires } })); }