[Rt-commit] r17759 - in rt/3.999/trunk: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Jan 15 23:53:52 EST 2009
Author: sunnavy
Date: Thu Jan 15 23:53:52 2009
New Revision: 17759
Modified:
rt/3.999/trunk/ (props changed)
rt/3.999/trunk/lib/RT/Model/User.pm
Log:
r18795 at sunnavys-mb: sunnavy | 2009-01-16 12:52:06 +0800
add our own password_is method for back compatibility support
Modified: rt/3.999/trunk/lib/RT/Model/User.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Model/User.pm (original)
+++ rt/3.999/trunk/lib/RT/Model/User.pm Thu Jan 15 23:53:52 2009
@@ -736,6 +736,37 @@
return 1;
}
+=head3 password_is
+
+Checks if the user's password matches the provided I<PASSWORD>.
+
+=cut
+
+sub password_is {
+ my $self = shift;
+ my $pass = shift;
+
+ return undef unless $self->__value('password');
+ my ($hash, $salt) = @{$self->__value('password')};
+ return 1 if ( $hash eq Digest::MD5::md5_hex($pass . $salt) );
+
+ # if it's a historical password we say ok.
+ my $value = $self->__raw_value('password');
+
+ my $md5 = Digest::MD5->new;
+ $md5->add($pass);
+ if ( $md5->hexdigest eq $value
+ || $value eq crypt( $pass, $value )
+ || $value eq $md5->b64digest )
+ {
+ $self->set_password($pass); # to update password in the new way
+ return 1;
+ }
+
+ return undef;
+
+}
+
=head3 generate_auth_token
Generate a random authentication string for the user.
More information about the Rt-commit
mailing list