public async Task <ActionResult> GetUser(string username) { if (string.IsNullOrEmpty(username)) { if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } username = User.Identity.Name; } var profile = await _userManager.FindByNameAsync(username); if (profile == null) { return(NotFound()); } var roles = await _userManager.GetRolesAsync(profile); var user = Models.App.User.FromUserProfile(profile, Url.Action("Show", "Avatar", new { name = profile.UserName }, Request.Scheme)); user.NickName = _nickNameProvider.GetNickName(user.UserName); user.Avatar = Url.Action("Show", "Avatar", new { name = profile.UserName }, Request.Scheme); user.Roles = roles; return(Json(user)); }
public string GetNickName(string user) { if (string.IsNullOrEmpty(user)) { return(string.Empty); } return(_nicknameProvider.GetNickName(user)); }