| CatalystX-SimpleLogin documentation | Contained in the CatalystX-SimpleLogin distribution. |
CatalystX::SimpleLogin::TraitFor::Controller::Login::OpenID - allows a User to login via OpenID
package MyApp::Controller::NeedsAuth;
sub something : Path Does('NeedsLogin') {
# Redirects to /login if not logged in
}
# Turn on in config
MyApp->config('Contoller::Login' => { traits => 'Login::OpenID' });
Provides the login action with a wrapper to redirect to a page which needs
authentication, from which the user was previously redirected. Goes hand in
hand with Catalyst::ActionRole::NeedsLogin .
Wrap around an openid authentication if the 'openid.mode' request parameter
is set. Otherwise, use the default login_GET() method.
See CatalystX::SimpleLogin for authors.
See CatalystX::SimpleLogin for license.
| CatalystX-SimpleLogin documentation | Contained in the CatalystX-SimpleLogin distribution. |
package CatalystX::SimpleLogin::TraitFor::Controller::Login::OpenID; use MooseX::MethodAttributes (); use MooseX::Types::Common::String qw/ NonEmptySimpleStr /; use Moose::Role -traits => 'MethodAttributes'; use namespace::autoclean; has 'openid_realm' => ( is => 'ro', isa => NonEmptySimpleStr, required => 1, default => 'openid', ); around 'login_GET' => sub { my $orig = shift; my $self = shift; my ( $c) = @_; if($c->req->param("openid.mode")) { if($c->authenticate({},$self->openid_realm)) { $c->flash(success_msg => "You signed in with OpenID!"); $c->res->redirect($self->redirect_after_login_uri($c)); } else { $c->flash(error_msg => "Failed to sign in with OpenID!"); } } else { return $self->$orig(@_); } };
1;