|
|
@ -7,6 +7,7 @@ use Exception;
|
|
|
|
use gateway\TranslationGateway;
|
|
|
|
use gateway\TranslationGateway;
|
|
|
|
use gateway\VocabularyListGateway;
|
|
|
|
use gateway\VocabularyListGateway;
|
|
|
|
use model\MdlStudent;
|
|
|
|
use model\MdlStudent;
|
|
|
|
|
|
|
|
use model\MdlUser;
|
|
|
|
use model\VocabularyList;
|
|
|
|
use model\VocabularyList;
|
|
|
|
use model\Translation;
|
|
|
|
use model\Translation;
|
|
|
|
|
|
|
|
|
|
|
@ -21,32 +22,29 @@ class UserController extends VisitorController
|
|
|
|
|
|
|
|
|
|
|
|
public function modifyPassword(): void {
|
|
|
|
public function modifyPassword(): void {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$userID = $_GET['user'];
|
|
|
|
global $user;
|
|
|
|
$currentPassword = Validation::val_password($_GET['currentPassword'] ?? null);
|
|
|
|
$currentPassword = Validation::val_password($_POST['currentPassword'] ?? null);
|
|
|
|
$newPassword = Validation::val_password($_GET['newPassword'] ?? null);
|
|
|
|
$newPassword = Validation::val_password($_POST['newPassword'] ?? null);
|
|
|
|
$confirmNewPassword = Validation::val_password($_GET['confirmNewPassword'] ?? null);
|
|
|
|
$confirmNewPassword = Validation::val_password($_POST['confirmNewPassword'] ?? null);
|
|
|
|
$mdl = new MdlStudent();
|
|
|
|
|
|
|
|
$user = $mdl->getUser($userID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($user->getPassword() != $currentPassword || $newPassword != $confirmNewPassword)
|
|
|
|
if (!password_verify($currentPassword, $user->getPassword()) || $newPassword != $confirmNewPassword)
|
|
|
|
throw new Exception("");
|
|
|
|
throw new Exception("");
|
|
|
|
|
|
|
|
|
|
|
|
$mdl->ModifyPassword($userID, $newPassword);
|
|
|
|
$mdl = new MdlUser();
|
|
|
|
$_GET['user'] = $userID;
|
|
|
|
$mdl->ModifyPassword($user->getId(), password_hash($newPassword, null));
|
|
|
|
$this->showAccountInfos();
|
|
|
|
$this->showAccountInfos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e){
|
|
|
|
catch (Exception $e){
|
|
|
|
throw new Exception("invalid entries");
|
|
|
|
throw new Exception("invalid entries".$e->getLine());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function modifyNickname(): void {
|
|
|
|
public function modifyNickname(): void {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$userID = Validation::filter_int($_GET['user'] ?? null);
|
|
|
|
global $user;
|
|
|
|
$newNickname = Validation::filter_str_nospecialchar($_GET['newNickname'] ?? null);
|
|
|
|
$newNickname = Validation::filter_str_nospecialchar($_POST['newNickname'] ?? null);
|
|
|
|
$mdl = new MdlStudent();
|
|
|
|
$mdl = new MdlStudent();
|
|
|
|
$mdl->modifyNickname($userID, $newNickname);
|
|
|
|
$mdl->modifyNickname($user->getId(), $newNickname);
|
|
|
|
$_GET['user'] = $userID;
|
|
|
|
|
|
|
|
$this->showAccountInfos();
|
|
|
|
$this->showAccountInfos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e){
|
|
|
|
catch (Exception $e){
|
|
|
|