sub searchargs_login : Global { my ( $self, $c ) = @_;
my $username = $c->request->params->{'username'} || '';
my $email = $c->request->params->{'email'} || '';
$c->authenticate({
password => $c->request->params->{'password'},
dbix_class => {
searchargs => [ { "-or" => [ username => $username,
email => $email ]},
{ prefetch => qw/ map_user_role /}
]
}
});
if ( $c->user_exists ) {
if ( $c->req->params->{detach} ) {
$c->detach( $c->req->params->{detach} );
}
$c->res->body( $c->user->get('username') . ' logged in' );
}
else {
$c->res->body( 'not logged in' );
}
}
sub resultset_login : Global { my ( $self, $c ) = @_;
my $username = $c->request->params->{'username'} || '';
my $email = $c->request->params->{'email'} || '';
my $rs = $c->model('TestApp::User')->search({ "-or" => [ username => $username,
email => $email ]});
$c->authenticate({
password => $c->request->params->{'password'},
dbix_class => { resultset => $rs }
});
if ( $c->user_exists ) {
if ( $c->req->params->{detach} ) {
$c->detach( $c->req->params->{detach} );
}
$c->res->body( $c->user->get('username') . ' logged in' );
}
else {
$c->res->body( 'not logged in' );
}
}