From 465f8ed1b317afb1c7aefde04e53118a19be1a18 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 29 Jan 2013 21:44:24 +0100 Subject: Finished the factoring of localpart-related methods. --- lib/Fripost/Schema/Auth.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/Fripost/Schema/Auth.pm') diff --git a/lib/Fripost/Schema/Auth.pm b/lib/Fripost/Schema/Auth.pm index d9c0267..f06ce4f 100644 --- a/lib/Fripost/Schema/Auth.pm +++ b/lib/Fripost/Schema/Auth.pm @@ -83,8 +83,8 @@ sub SASLauth { $self->suffix( ldap_explode_dn(@{$options{ldap_suffix}}) ); $self->whoami( $self->mail2dn($user) ); - $self->ldap( Net::LDAP::->new( $options{ldap_uri} // 'ldap://127.0.0.1:389/' - , async => 0 ) ); + $self->ldap( Net::LDAP::->new( $options{ldap_uri} + // 'ldap://127.0.0.1:389/' ) ); assert( $self->ldap, -die => "Couldn't connect to the LDAP server." ); my $callback; @@ -167,8 +167,8 @@ sub auth { $self->whoami( $self->mail2dn($user) ); } - $self->ldap( Net::LDAP::->new( $options{ldap_uri} // 'ldap://127.0.0.1:389/' - , async => 0 ) ); + $self->ldap( Net::LDAP::->new( $options{ldap_uri} + // 'ldap://127.0.0.1:389/' ) ); assert( $self->ldap, -die => "Couldn't connect to the LDAP server." ); my $mesg = $self->ldap->bind( $self->whoami, password => $pw ); @@ -253,7 +253,10 @@ converted to ASCII. sub mail2dn { my $self = shift; - my ($l,$d) = split_addr(shift, -encode => 'ascii') or return; + my $mail = shift // return; + + $mail =~ s/^\@//; + my ($l,$d) = split_addr($mail, -encode => 'ascii') or return; my @dn = ({fvd => $d}, @{$self->suffix}); unshift @dn, {fvl => $l} if $l; -- cgit v1.2.3