public async Task <IActionResult> Login([FromBody] UserForLoginDto userForLoginDto) { var user = await _authService.FindByNameAsync(userForLoginDto.Username); var result = await _authService.Login(userForLoginDto.Username, userForLoginDto.Password); if (result == null) { return(Unauthorized()); } var userprofile = new UserProfileDto() { User = new UserForReturnLogin { Username = user.Username, Role = user.Role, ID = user.ID, Alias = user.Alias, ListOCs = await _levelService.GetListID(user.LevelID), LevelOC = await _levelService.GetlevelOC(user.LevelID), IsActive = user.IsActive }, Menus = JsonConvert.SerializeObject(await _authService.GetMenusAsync(user.Role)) }; await _hubContext.Clients.All.SendAsync("updateCount"); return(Ok(new { token = GenerateJwtToken(new Models.ViewModels.Auth.UserLang { ID = result.ID, Username = result.Username, Alias = result.Alias, Permission = result.Permission, LevelID = result.LevelID, LevelOC = await _levelService.GetlevelOC(user.LevelID), IsActive = result.IsActive, Lang = "en" }), user = userprofile, })); }