Github user nir-sopher commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafficcontrol/pull/322#discussion_r103547967
  
    --- Diff: traffic_ops/app/lib/API/User.pm ---
    @@ -218,6 +218,118 @@ 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.");
    +   }
    +   
    +   
    +
    +   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                        => ( $params->{newUser} ) ? 1 : 
0,
    +           phone_number                    => 
defined_or_default($params->{phoneNumber}, ""),
    +           postal_code                     => 
defined_or_default($params->{postalCode}, ""),
    +           public_ssh_key                  => 
defined_or_default($params->{publicSshKey}, ""),
    +           registration_sent               => defined_or_default( 
$params->{registrationSent}, undef),
    +           role                            => $params->{role},
    +           state_or_province               => 
defined_or_default($params->{stateOrProvince}, ""),
    +           username                        => $params->{username},
    +           new_user                        => 
defined_or_default($params->{newUser}, 0),           
    +           uid                             => 
defined_or_default($params->{uid}, 0),               
    --- End diff --
    
    OK. Will remove it when I update this PR in the future


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to