Return user type on login

This commit is contained in:
Tom Bloor 2017-08-25 14:59:15 +01:00
parent 0a9ca57689
commit 4a4c568fb7

View file

@ -79,20 +79,12 @@ sub post_login {
if ( defined $user_result ) { if ( defined $user_result ) {
if ( $user_result->check_password($password) ) { if ( $user_result->check_password($password) ) {
my $session_key = $user_result->generate_session; 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;
}
return $c->render( json => { return $c->render( json => {
success => Mojo::JSON->true, success => Mojo::JSON->true,
session_key => $session_key, session_key => $session_key,
display_name => $display_name, display_name => $user_result->name,
user_type => $user_result->type,
}); });
} }
} }