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

@ -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({
customer => {
full_name => $validation->param('full_name'), full_name => $validation->param('full_name'),
display_name => $validation->param('display_name'), display_name => $validation->param('display_name'),
year_of_birth => $validation->param('year_of_birth'), year_of_birth => $validation->param('year_of_birth'),
postcode => $validation->param('postcode'), postcode => $validation->param('postcode'),
}); },
$c->schema->resultset('User')->create({ user => {
customer => $customer,
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({
organisation => {
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'),
sector => $validation->param('sector'), sector => $validation->param('sector'),
postcode => $validation->param('postcode'), postcode => $validation->param('postcode'),
}); },
$c->schema->resultset('User')->create({ user => {
organisation => $organisation,
email => $validation->param('email'), email => $validation->param('email'),
password => $validation->param('password'), password => $validation->param('password'),
},
type => 'organisation',
}); });
}); });
} }