Rewrote code for login info retrieval

This commit is contained in:
Finn 2017-07-26 16:45:46 +01:00
parent dfa1ba11f0
commit b0e9ef249a

View file

@ -79,13 +79,20 @@ sub post_login {
if ( defined $user_result ) {
if ( $user_result->check_password($password) ) {
my $session_key = $user_result->generate_session;
my $display_name;
if ( defined $user_result->customer_id ) {
$display_name = $user_result->customer->display_name;
} elsif ( defined $user_result->organisation_id ) {
$display_name = $user_result->organisation->name;
} else {
return undef;
}
return $c->render( json => {
success => Mojo::JSON->true,
session_key => $session_key,
full_name => $user_result->('full_name'),
display_name => $user_result->('display_name'),
postcode => $user_result->('postcode'),
display_name => $display_name,
});
}
}