diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml
index 3ae76ae..7ed5e21 100755
--- a/trunk/locale/en-us.xml
+++ b/trunk/locale/en-us.xml
@@ -188,10 +188,9 @@
viewcount
- account settings
+ account settings for
locale
choose pagesize
- choose your preferred method of video playback.
diff --git a/trunk/login.pl b/trunk/login.pl
index 5230a87..17558ed 100644
--- a/trunk/login.pl
+++ b/trunk/login.pl
@@ -31,106 +31,110 @@ if($query->param('action'))
#if login is requested
elsif($query->param('action') eq "login")
{
- #prepare query - empty password are openid users so omit those entries
- my $sth = $dbh->prepare(qq{select id from users
- where password = password( ? ) and username = ? and not password = '' limit 1 });
-
- #execute query
- $sth->execute($query->param('pass'), $query->param('user'));
-
- #if something was returned username and password match
- if($sth->fetchrow_array())
+ #if password is empty and username begins with http:// or ret is specified, then it's an openid login
+ if($query->param('pass') eq '' and ($query->param('user')=~m/^http:\/\// or $query->param('ret')))
{
- #store session id in database
- $dbh->do(qq{update users set sid = ? where username = ? }, undef, $session->id, $query->param('user')) or die $dbh->errstr;
- print $query->redirect("index.pl?information=information_logged_in");
- }
- else
- {
- #if not, print error
- $page->{'message'}->{'type'} = "error";
- $page->{'message'}->{'text'} = "error_username_password_do_not_match";
+ #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 );
- print output_page();
- }
-
- }
- 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 );
-
- #is an openid passed?
- if($query->param('user'))
- {
- #claim identity
- $claimed = $con->claimed_identity($query->param('user'));
- if(!defined($claimed))
+ #is an openid passed?
+ if($query->param('user'))
{
- print $session->header();
- print "claim failed: ", $con->err;
- }
- $check_url = $claimed->check_url(
- return_to => "$domain/login.pl?action=openid&ret=true", #on success return to this address
- trust_root => $domain); #this is the string the user will be asked to trust
-
- #redirect to openid server to check claim
- print $query->redirect($check_url);
- }
- #we return from an identity check
- elsif($query->param('ret'))
- {
- if($setup_url = $con->user_setup_url)
- {
- #redirect to setup url - user will give confirmation there
- print $query->redirect($setup_url);
- }
- elsif ($con->user_cancel)
- {
- #cancelled - redirect to login form
- print $session->header();
- print "cancelled";
- }
- elsif ($vident = $con->verified_identity)
- {
- #we are verified!!
- my $verified_url = $vident->url;
-
- #check if this openid user already is in database
- my $sth = $dbh->prepare(qq{select 1 from users where username = ? limit 1 });
- $sth->execute($verified_url);
- if($sth->fetchrow_array())
+ #claim identity
+ $claimed = $con->claimed_identity($query->param('user'));
+ if(!defined($claimed))
{
- #store session id in database
- $dbh->do(qq{update users set sid = ? where username = ? }, undef, $session->id, $verified_url) or die $dbh->errstr;
+ print $session->header();
+ print "claim failed: ", $con->err;
+ }
+ $check_url = $claimed->check_url(
+ return_to => "$domain/login.pl?action=login&ret=true", #on success return to this address
+ trust_root => $domain); #this is the string the user will be asked to trust
+
+ #redirect to openid server to check claim
+ print $query->redirect($check_url);
+ }
+ #we return from an identity check
+ elsif($query->param('ret'))
+ {
+ if($setup_url = $con->user_setup_url)
+ {
+ #redirect to setup url - user will give confirmation there
+ print $query->redirect($setup_url);
+ }
+ elsif ($con->user_cancel)
+ {
+ #cancelled - redirect to login form
+ print $session->header();
+ print "cancelled";
+ }
+ elsif ($vident = $con->verified_identity)
+ {
+ #we are verified!!
+ my $verified_url = $vident->url;
+
+ #check if this openid user already is in database
+ my $sth = $dbh->prepare(qq{select 1 from users where username = ? limit 1 });
+ $sth->execute($verified_url);
+ if($sth->fetchrow_array())
+ {
+ #store session id in database
+ $dbh->do(qq{update users set sid = ? where username = ? }, undef, $session->id, $verified_url) or die $dbh->errstr;
+ }
+ else
+ {
+ #add openid user to dabase
+ $dbh->do(qq{insert into users (username, sid) values ( ?, ? ) }, undef, $verified_url, $session->id) or die $dbh->errstr;
+ }
+
+ print $query->redirect("index.pl?information=information_logged_in");
}
else
{
- #add openid user to dabase
- $dbh->do(qq{insert into users (username, sid) values ( ?, ? ) }, undef, $verified_url, $session->id) or die $dbh->errstr;
+ #an error occured
+ print $session->header();
+ print "error validating identity: ", $con->err;
}
-
+ }
+ else
+ {
+ #if not, print login form
+ $page->{'loginform'}->{'action'} = 'openid';
+
+ print output_page();
+ }
+ }
+ #else it's a normal login
+ else
+ {
+ #prepare query - empty password are openid users so omit those entries
+ my $sth = $dbh->prepare(qq{select id from users
+ where password = password( ? ) and username = ? limit 1 });
+
+ #execute query
+ $sth->execute($query->param('pass'), $query->param('user'));
+
+ #if something was returned username and password match
+ if($sth->fetchrow_array())
+ {
+ #store session id in database
+ $dbh->do(qq{update users set sid = ? where username = ? }, undef, $session->id, $query->param('user')) or die $dbh->errstr;
print $query->redirect("index.pl?information=information_logged_in");
}
else
{
- #an error occured
- print $session->header();
- print "error validating identity: ", $con->err;
+ #if not, print error
+ $page->{'message'}->{'type'} = "error";
+ $page->{'message'}->{'text'} = "error_username_password_do_not_match";
+
+ print output_page();
}
}
- else
- {
- #if not, print login form
- $page->{'loginform'}->{'action'} = 'openid';
-
- print output_page();
- }
}
else
{
diff --git a/trunk/xsl/xhtml/settings.xsl b/trunk/xsl/xhtml/settings.xsl
index 3d57b66..cf755a5 100644
--- a/trunk/xsl/xhtml/settings.xsl
+++ b/trunk/xsl/xhtml/settings.xsl
@@ -13,6 +13,7 @@
+