Beispiel #1
0
        public IActionResult GetUser()
        {
            var userInfo = _tokenManager.ExtractUserInformation(User.Claims);
            var user     = _registrar.GetUser(userInfo.UserId);


            return(Ok(UserBasics.MapFromEntity(user)));
        }
Beispiel #2
0
        public IActionResult GetUserListing()
        {
            var users = _registrar.GetUserListing();

            var response = new List <UserBasics>();

            foreach (var user in users)
            {
                response.Add(UserBasics.MapFromEntity(user));
            }

            return(Ok(response));
        }
Beispiel #3
0
        public IActionResult EditUser([FromBody] UserRegistrationForm form)
        {
            var userInfo = _tokenManager.ExtractUserInformation(User.Claims);

            if (userInfo.Permissions != Permissions.ADMIN)
            {
                //If not admin, permissions cannot be changed. We use negative 1 to signify this.
                form.Permissions = -1;

                if (userInfo.UserId != form.UserId)
                {
                    return(BadRequest("You cannot modify this user."));
                }
            }

            var userId = _registrar.EditUser(form);

            if (userId == 0)
            {
                return(BadRequest("Invalid Password"));
            }

            return(Ok(UserBasics.MapFromEntity(_registrar.GetUser(userId))));
        }
Beispiel #4
0
        public IActionResult GetUser(int userId)
        {
            var user = _registrar.GetUser(userId);

            return(Ok(UserBasics.MapFromEntity(user)));
        }