Exemplo n.º 1
0
        public ActionResult <EditUserRequest> UpdateUser(string id, [FromBody] EditUserRequest updatedUserObj)
        {
            //var jwtFirebaseId = UserId;
            //User submittingUser = _repo.GetUserById(id);
            //if (updatedUserObj.FireBaseUid != jwtFirebaseId == false)
            //{
            //    // return 401 as the User they are passing in is not the same as the one making the request
            //    return Unauthorized();
            //}

            if (!_editUserValidator.Validate(updatedUserObj))
            {
                return(BadRequest(new { error = "NESVault User Object Validation Failed " }));
            }
            //return null;
            var updatedUser = _repo.UpdateUser(updatedUserObj);

            return(Ok(updatedUser));
        }
Exemplo n.º 2
0
        public ActionResult <EditUserRequest> UpdateUser(int id, [FromBody] EditUserRequest updatedUserObj)
        {
            var  jwtFirebaseId  = UserId;
            User submittingUser = _repo.GetUserById(jwtFirebaseId);

            if (updatedUserObj.FireBaseUid != jwtFirebaseId && submittingUser.IsAdmin == false)
            {
                // return 401 as the User they are passing in is not the same as the one making the request
                return(Unauthorized());
            }

            if (!_editUserValidator.Validate(updatedUserObj))
            {
                return(BadRequest(new { error = "User object validation failed " }));
            }
            //return null;
            var updatedUser = _repo.UpdateUser(updatedUserObj);

            return(Ok(updatedUser));
        }