diff --git a/app/controllers/profile.php b/app/controllers/profile.php index 9a8fb4e..e8fce4c 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -26,7 +26,7 @@ Router\post_action('profile', function () { $user_id = SessionStorage::getInstance()->getUserId(); $values = Request\values(); Helper\check_csrf_values($values); - list($valid, $errors) = Validator\User\validate_modification($values); + list($valid, $errors) = Validator\User\validate_profile_modification($user_id, $values); if ($valid) { $new_password = empty($values['password']) ? null : $values['password']; diff --git a/app/locales/ar_AR/translations.php b/app/locales/ar_AR/translations.php index 3effa0b..8b527bb 100644 --- a/app/locales/ar_AR/translations.php +++ b/app/locales/ar_AR/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/cs_CZ/translations.php b/app/locales/cs_CZ/translations.php index ce0985e..6bea226 100644 --- a/app/locales/cs_CZ/translations.php +++ b/app/locales/cs_CZ/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/de_DE/translations.php b/app/locales/de_DE/translations.php index 04b18b7..cae6b3b 100644 --- a/app/locales/de_DE/translations.php +++ b/app/locales/de_DE/translations.php @@ -251,4 +251,7 @@ return array( 'Edit' => 'Bearbeiten', 'The user id required' => 'Die Benutzer-ID wird benötigt', 'The username must be unique' => 'Der Benutzername muss einmalig sein', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/es_ES/translations.php b/app/locales/es_ES/translations.php index 8d9f0e1..2a2d851 100644 --- a/app/locales/es_ES/translations.php +++ b/app/locales/es_ES/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/fr_FR/translations.php b/app/locales/fr_FR/translations.php index ac2346c..4264378 100644 --- a/app/locales/fr_FR/translations.php +++ b/app/locales/fr_FR/translations.php @@ -251,4 +251,7 @@ return array( 'Edit' => 'Modifier', 'The user id required' => 'L\'ID de l\'utilisateur est obligatoire', 'The username must be unique' => 'Le nom d\'utilisateur doit être unique', + 'Current Password' => 'Mot de passe actuel', + 'New Password' => 'Nouveau mot de passe', + 'Wrong password' => 'Mauvais mot de passe', ); diff --git a/app/locales/it_IT/translations.php b/app/locales/it_IT/translations.php index b81ca7f..c0f32bf 100644 --- a/app/locales/it_IT/translations.php +++ b/app/locales/it_IT/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/ja_JP/translations.php b/app/locales/ja_JP/translations.php index d0dba79..b660d66 100644 --- a/app/locales/ja_JP/translations.php +++ b/app/locales/ja_JP/translations.php @@ -253,4 +253,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/pt_BR/translations.php b/app/locales/pt_BR/translations.php index b9f6dc6..8ebb2c6 100644 --- a/app/locales/pt_BR/translations.php +++ b/app/locales/pt_BR/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/ru_RU/translations.php b/app/locales/ru_RU/translations.php index caa8997..4b91571 100644 --- a/app/locales/ru_RU/translations.php +++ b/app/locales/ru_RU/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/sr_RS/translations.php b/app/locales/sr_RS/translations.php index f28b035..10a44ca 100644 --- a/app/locales/sr_RS/translations.php +++ b/app/locales/sr_RS/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/sr_RS@latin/translations.php b/app/locales/sr_RS@latin/translations.php index d7601ae..2d11723 100644 --- a/app/locales/sr_RS@latin/translations.php +++ b/app/locales/sr_RS@latin/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/tr_TR/translations.php b/app/locales/tr_TR/translations.php index ad95797..e60a3ba 100644 --- a/app/locales/tr_TR/translations.php +++ b/app/locales/tr_TR/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/locales/zh_CN/translations.php b/app/locales/zh_CN/translations.php index 39dceeb..c708251 100644 --- a/app/locales/zh_CN/translations.php +++ b/app/locales/zh_CN/translations.php @@ -251,4 +251,7 @@ return array( // 'Edit' => '', // 'The user id required' => '', // 'The username must be unique' => '', + // 'Current Password' => '', + // 'New Password' => '', + // 'Wrong password' => '', ); diff --git a/app/templates/profile.php b/app/templates/profile.php index b4051fe..d2e3ea3 100644 --- a/app/templates/profile.php +++ b/app/templates/profile.php @@ -23,13 +23,16 @@ -
+ - -
+ + + + + -
+
diff --git a/app/validators/user.php b/app/validators/user.php index 2cda757..fb21d8e 100644 --- a/app/validators/user.php +++ b/app/validators/user.php @@ -10,6 +10,26 @@ use PicoDb\Database; use SimpleValidator\Validator; use SimpleValidator\Validators; +function validate_profile_modification($user_id, array $values) +{ + list($result, $errors) = validate_modification($values); + + if ($result) { + $user = UserModel\get_user_by_id($user_id); + $password = ! empty($values['current_password']) ? $values['current_password'] : ''; + + if (! password_verify($password, $user['password'])) { + $result = false; + $errors['current_password'][] = t('Wrong password'); + } + } + + return array( + $result, + $errors, + ); +} + function validate_modification(array $values) { $v = new Validator($values, array(