X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FApp-EzPz.git;a=blobdiff_plain;f=lib%2FApp%2FEzPz%2FUser.pm;fp=lib%2FApp%2FEzPz%2FUser.pm;h=a4da2f1195c11af17561d5a281752560f55fd9c5;hp=e3d843b178970ab1d4679dfd71735315d3b55cd8;hb=396f4b0bc4a7e5a42cf276de9ff38aaa63748a23;hpb=5b26866ea3dc1b51e669b9e213d002c05de81e14 diff --git a/lib/App/EzPz/User.pm b/lib/App/EzPz/User.pm index e3d843b..a4da2f1 100644 --- a/lib/App/EzPz/User.pm +++ b/lib/App/EzPz/User.pm @@ -1,6 +1,6 @@ package App::EzPz::User; -use Authen::Htpasswd::User; +use Module::Runtime qw(use_module); use Moo; has _htpasswd_user => ( @@ -8,14 +8,49 @@ has _htpasswd_user => ( handles => [ qw(username password check_password) ], ); +has ezmlm_bindir => (is => 'rwp'); + around BUILDARGS => sub { my ($orig, $self) = (shift, shift); my $args = $self->$orig(@_); $args->{htpasswd_user} ||= - Authen::Htpasswd::User->new( + use_module('Authen::Htpasswd::User')->new( delete @{$args}{qw(username password)} ); return $args }; +sub list_names { + my ($self) = @_; + if (my $unsplit = ($self->_htpasswd_user->extra_info||[])->[0]) { + return split /\s*,\s*/, $unsplit; + } else { + return (); + } +} + +sub set_list_names { + my ($self, @names) = @_; + my @extra = @{$self->_htpasswd_user->extra_info||[]}; + $extra[0] = join(', ', @names); + $self->_htpasswd_user->extra_info(@extra); + return; +} + +sub add_list_name { + my ($self, $name) = @_; + my %names; @names{my @names = $self->list_names} = (); + $self->set_list_names(@names, $name) unless exists $names{$name}; + return $name; +} + +sub remove_list_name { + my ($self, $name) = @_; + my %names; @names{my @names = $self->list_names} = (); + if (exists $names{$name}) { + $self->set_list_names(grep !($_ eq $name), $self->list_names) + } + return $name; +} + 1;