Github user nir-sopher commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/370#discussion_r110659889 --- Diff: traffic_ops/app/lib/API/User.pm --- @@ -226,6 +226,120 @@ sub update { } +# Create +sub create { + my $self = shift; + my $params = $self->req->json; + + if ( !&is_oper($self) ) { + return $self->forbidden(); + } + + my $name = $params->{username}; + if ( !defined($name) ) { + return $self->alert("Username is required."); + } + + my $existing = $self->db->resultset('TmUser')->search( { username => $name } )->single(); + if ($existing) { + return $self->alert("A user with username \"$name\" already exists."); + } + + + if ( !defined($params->{fullName}) ) { + return $self->alert("full-name is required."); + } + + if ( !defined($params->{email}) ) { + return $self->alert("email is required."); + } + + if ( !defined($params->{localPassword}) ) { + return $self->alert("local-password is required."); + } + + if ( !defined($params->{confirmLocalPassword}) ) { + return $self->alert("confirm-local-password is required."); + } + + if ($params->{localPassword} ne $params->{confirmLocalPassword}){ + return $self->alert("local-password and confirmed-local-password mismatch."); + } + + if ( !defined($params->{role}) ) { + return $self->alert("role is required."); + } + + #setting tenant_id to the user's tenant if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API + my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} : $self->current_user_tenant(); + + my $values = { + address_line1 => defined_or_default($params->{addressLine1}, ""), + address_line2 => defined_or_default($params->{addressLine2}, ""), + city => defined_or_default($params->{city}, ""), + company => defined_or_default($params->{company}, ""), + country => defined_or_default($params->{country}, ""), + email => $params->{email}, + full_name => $params->{fullName}, + new_user => defined_or_default($params->{newUser}, 0), --- End diff -- Done. "0" an not "\0" as setting it to "\0" failed. Will need to look further into it to understand why
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---