X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/58fdd50dbb6b909d48b2846f36857b2bd2219441..d0c2cfbef2bfa708dad6df15c76daa81d4fda3ab:/SL/Auth/Password.pm diff --git a/SL/Auth/Password.pm b/SL/Auth/Password.pm index 9b0f1aec7..5a17203c5 100644 --- a/SL/Auth/Password.pm +++ b/SL/Auth/Password.pm @@ -35,11 +35,19 @@ sub hash { } } +sub hash_if_unhashed { + my ($class, %params) = @_; + + my ($algorithm, $password) = $class->parse($params{password}, 'NONE'); + + return $algorithm eq 'NONE' ? $class->hash(%params) : $params{password}; +} + sub parse { - my ($class, $password) = @_; + my ($class, $password, $default_algorithm) = @_; return ($1, $2) if $password =~ m/^\{ ([^\}]+) \} (.+)/x; - return ('CRYPT', $password); + return ($default_algorithm || 'CRYPT', $password); } 1;