From eaacbeb2d5fece7fe9cab570f262a8f29be96863 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 10 Sep 2012 20:01:06 +0200 Subject: Internationalization. --- lib/Fripost/Panel/Login.pm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/Fripost/Panel/Login.pm') diff --git a/lib/Fripost/Panel/Login.pm b/lib/Fripost/Panel/Login.pm index 8dcfd2b..a147371 100644 --- a/lib/Fripost/Panel/Login.pm +++ b/lib/Fripost/Panel/Login.pm @@ -19,10 +19,10 @@ use CGI::Application::Plugin::Authentication; use CGI::Application::Plugin::Redirect; use CGI::Application::Plugin::ConfigAuto 'cfg'; -use Net::LDAP; -use Authen::SASL; +use Fripost::Schema; use File::Spec::Functions qw/catfile catdir/; use HTML::Entities; +use Net::IDN::Encode qw/email_to_ascii/; # This method is called right before the 'setup' method below. It @@ -56,19 +56,22 @@ sub cgiapp_init { $self->authen->config( DRIVER => [ 'Generic', sub { my ($u,$p) = @_; - my ($l,$d) = split /\@/, $u, 2; + my $d = (split /\@/, $u, 2)[1]; unless (defined $d) { $CFG{default_realm} // return 0; - $d = $CFG{default_realm}; - $u .= '@'.$d; + $u .= '@'.$CFG{default_realm}; } - my $bind_dn = "fvu=$l,fvd=$d,". join (',', @{$CFG{ldap_suffix}}); - - my $ldap = Net::LDAP->new( $CFG{ldap_uri} ); - my $mesg = $ldap->bind ( $bind_dn, password => $p ); - $ldap->unbind; - $mesg->code ? 0 : $u; + Encode::_utf8_on($u); + $u = Net::IDN::Encode::email_to_ascii($u); + my $fp = Fripost::Schema::->auth($u, $p, + ldap_uri => $CFG{ldap_uri}, + ldap_suffix => $CFG{ldap_suffix}, + -die => 0 + ); + return 0 unless defined $fp; + $fp->done; + return $u; } ], STORE => 'Session', LOGIN_RUNMODE => 'login', -- cgit v1.2.3