public async Task <ActionResult <User> > GetUser() { UserClaims userClaims = UserClaims.FromClaimsPrincipal(User); if (userClaims == null) { return(Unauthorized()); } return(await usersRepository.GetByIdAsync(userClaims.Id)); }
public async Task <ActionResult <IEnumerable <User> > > GetUser() { UserClaims userClaims = UserClaims.FromClaimsPrincipal(User); if (userClaims == null || !userClaims.IsAdmin) { return(Unauthorized()); } return(new ActionResult <IEnumerable <User> >(await usersRepository.ListAsync())); }