更新用户控制器中的JWT声明名称,并在用户资料中添加菜单信息字段
This commit is contained in:
parent
9f407c422c
commit
062c5f9477
@ -39,21 +39,20 @@ public class UserControllers:ControllerBase
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> My()
|
public async Task<IActionResult> My()
|
||||||
{
|
{
|
||||||
string userId = this.User.FindFirst(JwtRegisteredClaimNames.Sub)!.Value;
|
|
||||||
if (string.IsNullOrEmpty(userId))
|
|
||||||
{
|
|
||||||
return Ok(new ReturnTemplate(500,"获取用户失败(JWT解析错误)",null));
|
|
||||||
}
|
string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var userProfile = await _userService.GetUserProfileAsync(userId);
|
var userProfile = await _userService.GetUserProfileAsync(userId);
|
||||||
return Ok(new ReturnTemplate(200,"获取成功!",userProfile));
|
return Ok(new ReturnTemplate(200, "获取成功!", userProfile));
|
||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
return NotFound(ex.Message);
|
return NotFound(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,4 +11,6 @@ public class UserProfile
|
|||||||
public string? JobCode { get; set; }
|
public string? JobCode { get; set; }
|
||||||
public string? JobName { get; set; }
|
public string? JobName { get; set; }
|
||||||
public string? Birthday { get; set; }
|
public string? Birthday { get; set; }
|
||||||
|
public string? MenuCode { get; set; }
|
||||||
|
public string? MenuName { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@ public class UserService
|
|||||||
Config = user.Config,
|
Config = user.Config,
|
||||||
JobCode = user.JobCode,
|
JobCode = user.JobCode,
|
||||||
JobName = user.JobName,
|
JobName = user.JobName,
|
||||||
Birthday = user.Birthday
|
Birthday = user.Birthday,
|
||||||
|
MenuCode = user.MenuCode,
|
||||||
|
MenuName = user.MenuName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user