Permalink
Browse files

add set_password method

  • Loading branch information...
1 parent 475ffec commit faad8330ca3d742e657812cd43e1101984062c8c @nothingmuch committed Apr 13, 2009
Showing with 8 additions and 1 deletion.
  1. +7 −0 lib/KiokuX/User/Password.pm
  2. +1 −1 t/basic.t
@@ -5,6 +5,8 @@ use Moose::Role;
use MooseX::Types::Authen::Passphrase qw(Passphrase);
+use KiokuX::User::Util qw(crypt_password);
+
use namespace::clean -except => 'meta';
has password => (
@@ -20,6 +22,11 @@ sub check_password {
$self->password->match(@_);
}
+sub set_password {
+ my ( $self, @args ) = @_;
+ $self->password( crypt_password(@args) );
+}
+
__PACKAGE__
__END__
View
@@ -39,7 +39,7 @@ ok !$o->check_password("fooo"), "bad password";
is eval { $o->id("lala") }, undef, "can't change ID";
-$o->password( crypt_password( passphrase => "bar" ) );
+$o->set_password("bar");
ok !$o->check_password("foo"), "password changed";

0 comments on commit faad833

Please sign in to comment.