public override async Task <WhoAmIReply> WhoAmI(Empty request, ServerCallContext context) { AppUser?user = await _userManager.GetUserAsync(context.GetHttpContext().User); WhoAmIReply result = new WhoAmIReply(); SystemSetting?installedSetting = await _authDbContext.SystemSettings .SingleOrDefaultAsync(s => s.Name == "installer.is_installed" && s.Value == "true"); result.IsInstalled = (installedSetting != null); if (user != null) { result.IsAuthenticated = true; result.UserId = user.Id.ToString(); result.Roles.AddRange(await _userManager.GetRolesAsync(user)); if (_profileImageManager.HasProfileImage(user.Id)) { result.ProfilePicture = "/api/profile/image/" + user.Id.ToString(); } result.UserName = user.UserName; } else { result.IsAuthenticated = false; } return(result); }
public IActionResult GetProfileImage(Guid userId) { if (_profileImageManager.HasProfileImage(userId)) { return(File(_profileImageManager.GetImageStream(userId, System.IO.FileMode.Open), "image/jpeg")); } return(NotFound()); }
public override async Task <UserListReply> ListUsers(Empty request, ServerCallContext context) { IEnumerable <AppUser> users = _userManager.GetAllUsers(); UserListReply reply = new UserListReply { }; foreach (AppUser user in users) { User userElement = new User { Id = user.Id.ToString(), Name = user.UserName, Email = user.Email, IsAdmin = await _userManager.IsInRoleAsync(user, ADMIN_ROLE), IsEnabled = !user.IsDisabled, HasPicture = _profileImageManager.HasProfileImage(user.Id), }; reply.Users.Add(userElement); } return(reply); }