Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Created November 30, 2008 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/30478 to your computer and use it in GitHub Desktop.
Save marcusramberg/30478 to your computer and use it in GitHub Desktop.
sub openid : Global {
my ($self,$c) = @_;
eval {
if ($c->authenticate({},'openid')) {
if (my $person=$c->find_user({
dbix_class=>{
searchargs=>
[ {'openids.id'=>$c->user->{url} },
{join=>[qw/openids/]}
]}})) {
$c->set_authenticated($person);
return $c->res->redirect($c->uri_for('/',$person->login));
}
my $openid:Stashed=$c->user->url;
$c->logout;
}
elsif (! @{$c->error}) {
return if $c->res->redirect;
$c->res->redirect($c->uri_for('/login',{openid_failed=>1}));
}
};
if ($@) {
$@ =~ s/\sat\s\S+\sline\s\d+$//;
$c->stash->{omessage} = $@;
$c->error(0);
$c->logout;
$c->detach('/user/login');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment