Fix User endpoints for entity upgrade
This commit is contained in:
parent
dd6e21eb50
commit
adfcd8880f
1 changed files with 12 additions and 12 deletions
|
@ -65,12 +65,12 @@ sub post_account {
|
||||||
my $postcode;
|
my $postcode;
|
||||||
|
|
||||||
#Needs elsif added for trader page for this similar relevant entry
|
#Needs elsif added for trader page for this similar relevant entry
|
||||||
if ( defined $user_result->customer_id ) {
|
if ( $user_result->type eq 'customer' ) {
|
||||||
$full_name = $user_result->customer->full_name;
|
$full_name = $user_result->entity->customer->full_name;
|
||||||
$display_name = $user_result->customer->display_name;
|
$display_name = $user_result->entity->customer->display_name;
|
||||||
$postcode = $user_result->customer->postcode;
|
$postcode = $user_result->entity->customer->postcode;
|
||||||
} elsif ( defined $user_result->organisation_id ) {
|
} elsif ( $user_result->type eq 'organisation' ) {
|
||||||
$display_name = $user_result->organisation->name;
|
$display_name = $user_result->entity->organisation->name;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -121,10 +121,10 @@ sub post_account_update {
|
||||||
$validation->required('postcode')->postcode;
|
$validation->required('postcode')->postcode;
|
||||||
$validation->optional('new_password');
|
$validation->optional('new_password');
|
||||||
|
|
||||||
if ( defined $user->customer_id ) {
|
if ( $user->type eq 'customer' ) {
|
||||||
$validation->required('display_name');
|
$validation->required('display_name');
|
||||||
$validation->required('full_name');
|
$validation->required('full_name');
|
||||||
} elsif ( defined $user->organisation_id ) {
|
} elsif ( $user->type eq 'organisation' ) {
|
||||||
$validation->required('name');
|
$validation->required('name');
|
||||||
$validation->required('street_name');
|
$validation->required('street_name');
|
||||||
$validation->required('town');
|
$validation->required('town');
|
||||||
|
@ -133,10 +133,10 @@ sub post_account_update {
|
||||||
|
|
||||||
return $c->api_validation_error if $validation->has_error;
|
return $c->api_validation_error if $validation->has_error;
|
||||||
|
|
||||||
if ( defined $user->customer_id ){
|
if ( $user->type eq 'customer' ){
|
||||||
|
|
||||||
$c->schema->txn_do( sub {
|
$c->schema->txn_do( sub {
|
||||||
$user->customer->update({
|
$user->entity->customer->update({
|
||||||
full_name => $validation->param('full_name'),
|
full_name => $validation->param('full_name'),
|
||||||
display_name => $validation->param('display_name'),
|
display_name => $validation->param('display_name'),
|
||||||
postcode => $validation->param('postcode'),
|
postcode => $validation->param('postcode'),
|
||||||
|
@ -148,10 +148,10 @@ sub post_account_update {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( defined $user->organisation_id ) {
|
elsif ( $user->type eq 'organisation' ) {
|
||||||
|
|
||||||
$c->schema->txn_do( sub {
|
$c->schema->txn_do( sub {
|
||||||
$user->organisation->update({
|
$user->entity->organisation->update({
|
||||||
name => $validation->param('name'),
|
name => $validation->param('name'),
|
||||||
street_name => $validation->param('street_name'),
|
street_name => $validation->param('street_name'),
|
||||||
town => $validation->param('town'),
|
town => $validation->param('town'),
|
||||||
|
|
Reference in a new issue