X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FUser.pm;h=af4a6ad99b72e100f366b96a73b70556fa7bb27e;hp=018ac8a62fff83349d4083346e928981ae897123;hb=0ea23112cfa0d82738b0f08d60d90579721b7524;hpb=60dd95422a1ad4724e0c5d9dd7f8e8878cd96aa8 diff --git a/rt/lib/RT/User.pm b/rt/lib/RT/User.pm index 018ac8a62..af4a6ad99 100755 --- a/rt/lib/RT/User.pm +++ b/rt/lib/RT/User.pm @@ -957,7 +957,7 @@ sub IsPassword { my $hash = MIME::Base64::decode_base64($stored); # Decoding yields 30 byes; first 4 are the salt, the rest are substr(SHA256,0,26) my $salt = substr($hash, 0, 4, ""); - return 0 unless substr(Digest::SHA::sha256($salt . Digest::MD5::md5($value)), 0, 26) eq $hash; + return 0 unless substr(Digest::SHA::sha256($salt . Digest::MD5::md5(encode_utf8($value))), 0, 26) eq $hash; } elsif (length $stored == 32) { # Hex nonsalted-md5 return 0 unless Digest::MD5::md5_hex(encode_utf8($value)) eq $stored; @@ -1390,6 +1390,28 @@ sub SetPreferences { } } +=head2 DeletePreferences NAME/OBJ VALUE + +Delete user preferences associated with given object or name. + +=cut + +sub DeletePreferences { + my $self = shift; + my $name = _PrefName( shift ); + + return (0, $self->loc("No permission to set preferences")) + unless $self->CurrentUserCanModify('Preferences'); + + my $attr = RT::Attribute->new( $self->CurrentUser ); + $attr->LoadByNameAndObject( Object => $self, Name => $name ); + if ( $attr->Id ) { + return $attr->Delete; + } + + return (0, $self->loc("Preferences were not found")); +} + =head2 Stylesheet Returns a list of valid stylesheets take from preferences.