示例#1
0
        public async Task <IActionResult> Create([FromBody] CreateUserRequest request)
        {
            try
            {
                if (request.Key == Auth.ADMIN_NAME_CLAIM_VALUE)
                {
                    _logger.LogError($"Attempted to create user with Admin name '{Auth.ADMIN_NAME_CLAIM_VALUE}'");
                    return(StatusCode(StatusCodes.Status403Forbidden));
                }

                var newUser = await _hiarcDatabase.CreateUser(request);

                var uri = $"{_hiarcSettings.BaseUri}/users/{newUser.Key}";

                return(Created(uri, newUser));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }