public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] SecretDto dto) { var userProfile = _jwtApp.GetExistenceToken(dto.Token); var user = new UserDto { UserName = userProfile.Name, Id = userProfile.UserId, RoleName = userProfile.RoleNames }; var jwt = await _jwtApp.RefreshAsync(dto.Token, user); var data = new JwtResponseDto { Access = jwt.Token, Type = "Bearer", Profile = new Profile { RoleNames = user.RoleName, UserId = user.Id, UserName = user.UserName, Auths = jwt.Success ? jwt.AuthTime : 0, Expires = jwt.Success ? jwt.ExpTime : 0 } }; return(new JsonResult( new { code = 20000, data })); }
public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] SecretDto dto) { //Todo:获取用户信息 var user = _secretApp.GetCurrentUserAsync(dto.Account, dto.Password); 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 } })); }
public IActionResult RefreshAccessToken(SecretDto dto) { //Todo:获取用户信息 var user = _homeBus.JwtSubmitLogin(dto.username, dto.password); if (user == null) { return(Ok( new AjaxResult { Success = false, Msg = "用户名或密码错误!", Data = new JwtResponseDto { Access = "用户名或密码错误!", Type = "Bearer", Profile = new Profile { UserName = dto.username, Auths = 0, Expires = 0 } }, ErrorCode = 0 })); } var jwt = _jwtApp.RefreshAsync(dto.Token, user); return(Ok( new AjaxResult { Success = true, Msg = "Token刷新成功!", Data = new JwtResponseDto { Access = jwt.Token, Type = "Bearer", Profile = new Profile { UserId = user.UserId, UserName = user.UserName, RealName = user.RealName, Auths = jwt.Success ? jwt.Auths : 0, Expires = jwt.Success ? jwt.Expires : 0 } }, ErrorCode = 0 })); }
public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] SecretDto dto) { var auth = HttpContext.AuthenticateAsync().Result.Principal.Claims; //Todo:获取用户信息 //var user = new UserDto //{ // Id = Guid.NewGuid(), // UserName = "******", // Role = Guid.Empty, // Email = "*****@*****.**", // Phone = "13912345678", //}; var user = await _secretApp.GetCurrentUserAsync(dto.UserName, dto.Password); if (user == null) { return(Ok(new JwtResponseDto { Access = "无权访问", Type = "Bearer", err_code = 1, Data = new Profile { Name = dto.UserName, Auths = 0, Expires = 0 } })); } var jwt = await _jwtApp.RefreshAsync(dto.Token, user); return(Ok(new JwtResponseDto { Access = jwt.Token, err_code = 0, Type = "Bearer", Data = new Profile { Name = user.UserName, Auths = jwt.Success ? jwt.Auths : 0, Expires = jwt.Success ? jwt.Expires : 0 } })); }
public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] SecretDto dto) { //Todo:获取用户信息 var user = new UserDto { Id = Guid.NewGuid(), UserName = "******", Role = Guid.Empty, Email = "*****@*****.**", 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 } })); }
public async Task <IActionResult> RefreshAccessTokenAsync([FromBody] SecretDto dto) { var auth = HttpContext.AuthenticateAsync().Result.Principal.Claims; var user = await _userApp.QueryFirst(p => p.Name == dto.UserName& p.Password == dto.Password); if (user == null) { return(Ok(new JwtResponseDto { Access = "无权访问", Type = "Bearer", err_code = 1, Data = new Profile { Name = dto.UserName, Auths = 0, Expires = 0 } })); } var jwt = await _jwtApp.RefreshAsync(dto.Token, user); return(Ok(new JwtResponseDto { Access = jwt.Token, err_code = 0, Type = "Bearer", Data = new Profile { Name = user.Name, Auths = jwt.Success ? jwt.Auths : 0, Expires = jwt.Success ? jwt.Expires : 0 } })); }