Rewrote code for login info retrieval
This commit is contained in:
parent
dfa1ba11f0
commit
b0e9ef249a
1 changed files with 10 additions and 3 deletions
|
@ -79,13 +79,20 @@ 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 undef;
|
||||||
|
}
|
||||||
|
|
||||||
return $c->render( json => {
|
return $c->render( json => {
|
||||||
success => Mojo::JSON->true,
|
success => Mojo::JSON->true,
|
||||||
session_key => $session_key,
|
session_key => $session_key,
|
||||||
full_name => $user_result->('full_name'),
|
display_name => $display_name,
|
||||||
display_name => $user_result->('display_name'),
|
|
||||||
postcode => $user_result->('postcode'),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue