restructured openid login

git-svn-id: http://yolanda.mister-muffin.de/svn@268 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-03 16:20:52 +00:00
parent 861e15f468
commit fb3064b6c3

View file

@ -26,7 +26,7 @@ elsif($userinfo->{'username'})
print output_page(); print output_page();
} }
#if password is empty and username begins with http:// or ret is specified, then it's an openid login #if password is empty and username begins with http:// or ret is specified, then it's an openid login
elsif($query->param('pass') eq '' and ($query->param('user')=~m/^http:\/\// or $query->param('ret'))) elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//)
{ {
#create our openid consumer object #create our openid consumer object
$con = Net::OpenID::Consumer->new( $con = Net::OpenID::Consumer->new(
@ -47,15 +47,31 @@ elsif($query->param('pass') eq '' and ($query->param('user')=~m/^http:\/\// or $
print "claim failed: ", $con->err; print "claim failed: ", $con->err;
} }
$check_url = $claimed->check_url( $check_url = $claimed->check_url(
return_to => "$domain/login.pl?action=login&ret=true", #on success return to this address return_to => "$domain/login.pl?action=openid", #on success return to this address
trust_root => $domain); #this is the string the user will be asked to trust trust_root => $domain); #this is the string the user will be asked to trust
#redirect to openid server to check claim #redirect to openid server to check claim
print $query->redirect($check_url); print $query->redirect($check_url);
} }
#we return from an identity check else
elsif($query->param('ret'))
{ {
#if not, print login form
$page->{'loginform'} = [''];
print output_page();
}
}
#we return from an identity check
elsif($query->param('action') eq 'openid')
{
#create our openid consumer object
$con = Net::OpenID::Consumer->new(
ua => LWPx::ParanoidAgent->new, # FIXME - use LWPx::ParanoidAgent
cache => undef, # or File::Cache->new,
args => $query,
consumer_secret => $session->id, #is this save? don't know...
required_root => $domain );
if($setup_url = $con->user_setup_url) if($setup_url = $con->user_setup_url)
{ {
#redirect to setup url - user will give confirmation there #redirect to setup url - user will give confirmation there
@ -94,14 +110,6 @@ elsif($query->param('pass') eq '' and ($query->param('user')=~m/^http:\/\// or $
print $session->header(); print $session->header();
print "error validating identity: ", $con->err; print "error validating identity: ", $con->err;
} }
}
else
{
#if not, print login form
$page->{'loginform'} = [''];
print output_page();
}
} }
#else it's a normal login #else it's a normal login
elsif($query->param('pass') ne '' and $query->param('user')!~m/^http:\/\// and $query->param('user') ne '') elsif($query->param('pass') ne '' and $query->param('user')!~m/^http:\/\// and $query->param('user') ne '')