move chane password code from keymanager.php to crypt.php

This commit is contained in:
Bjoern Schiessle 2012-08-15 09:54:21 +02:00
parent 6ce315fe58
commit 92ec88c7bc
2 changed files with 8 additions and 22 deletions

View file

@ -447,26 +447,18 @@ class Crypt {
}
public static function changekeypasscode($oldPassword, $newPassword) {
if(\OCP\User::isLoggedIn()){
$username = \OCP\USER::getUser();
$view = new \OC_FilesystemView('/'.$username);
// read old key
$key = Keymanager::getPrivateKey();
// decrypt key with old passcode
if ( ($key = self::decrypt($key, $oldPassword)) ) {
// encrypt again with new passcode
$key = self::encrypt($key, $newPassword);
// store the new key
return Keymanager::setPrivateKey($key);
} else {
return false;
if ( ($key = Crypt::symmetricDecryptFileContent($key,$oldpasswd)) ) {
if ( ($key = Crypt::symmetricEncryptFileContent($key, $newpasswd)) ) {
Keymanager::setPrivateKey($key);
return true;
}
}
}
return false;
}
}
?>

View file

@ -219,13 +219,7 @@ class Keymanager {
public static function changePasswd($oldpasswd, $newpasswd) {
if ( \OCP\User::checkPassword(\OCP\User::getUser(), $newpasswd) ) {
$key = Keymanager::getPrivateKey();
if ( ($key = Crypt::symmetricDecryptFileContent($key,$oldpasswd)) ) {
if ( ($key = Crypt::symmetricEncryptFileContent($key, $newpasswd)) ) {
Keymanager::setPrivateKey($key);
return true;
}
}
return Crypt::changekeypasscode($oldpasswd, $newpasswd);
}
return false;