Fix register for new entity work

This commit is contained in:
Tom Bloor 2017-08-31 16:46:25 +01:00
parent 4cc8aad367
commit bf16077b10

View file

@ -48,7 +48,7 @@ has error_messages => sub {
}; };
}; };
sub post_register{ sub post_register {
my $c = shift; my $c = shift;
my $validation = $c->validation; my $validation = $c->validation;
@ -87,17 +87,19 @@ sub post_register{
name => $validation->param('token'), name => $validation->param('token'),
used => 0, used => 0,
})->update({ used => 1 }); })->update({ used => 1 });
# Create customer as a seperate step, so we dont leak data
my $customer = $c->schema->resultset('Customer')->create({ $c->schema->resultset('Entity')->create({
full_name => $validation->param('full_name'), customer => {
display_name => $validation->param('display_name'), full_name => $validation->param('full_name'),
year_of_birth => $validation->param('year_of_birth'), display_name => $validation->param('display_name'),
postcode => $validation->param('postcode'), year_of_birth => $validation->param('year_of_birth'),
}); postcode => $validation->param('postcode'),
$c->schema->resultset('User')->create({ },
customer => $customer, user => {
email => $validation->param('email'), email => $validation->param('email'),
password => $validation->param('password'), password => $validation->param('password'),
},
type => 'customer',
}); });
}); });
@ -109,17 +111,19 @@ sub post_register{
name => $validation->param('token'), name => $validation->param('token'),
used => 0, used => 0,
})->update({ used => 1 }); })->update({ used => 1 });
my $organisation = $c->schema->resultset('Organisation')->create({ $c->schema->resultset('Entity')->create({
name => $validation->param('name'), organisation => {
street_name => $validation->param('street_name'), name => $validation->param('name'),
town => $validation->param('town'), street_name => $validation->param('street_name'),
sector => $validation->param('sector'), town => $validation->param('town'),
postcode => $validation->param('postcode'), sector => $validation->param('sector'),
}); postcode => $validation->param('postcode'),
$c->schema->resultset('User')->create({ },
organisation => $organisation, user => {
email => $validation->param('email'), email => $validation->param('email'),
password => $validation->param('password'), password => $validation->param('password'),
},
type => 'organisation',
}); });
}); });
} }