diff --git a/rest/index.php b/rest/index.php index 23ece3109ecec222381bba891e6a2cd400d6f7fe..50d89efec8246ba9d55716b0451457d2a99a5c79 100755 --- a/rest/index.php +++ b/rest/index.php @@ -401,7 +401,6 @@ $app->delete('/users/{id}', \User\controllers\UserController::class . ':delete') $app->put('/users/{id}/suspend', \User\controllers\UserController::class . ':suspend'); $app->get('/users/{id}/isDeletable', \User\controllers\UserController::class . ':isDeletable'); $app->get('/users/{id}/details', \User\controllers\UserController::class . ':getDetailledById'); -$app->post('/users/{id}/password', \User\controllers\UserController::class . ':resetPassword'); $app->put('/users/{id}/password', \User\controllers\UserController::class . ':updatePassword'); $app->get('/users/{userId}/status', \User\controllers\UserController::class . ':getStatusByUserId'); $app->put('/users/{id}/status', \User\controllers\UserController::class . ':updateStatus'); diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 50b104d5372da0d31a258d3e62d0dfd2a84c3612..1e2dae2b861ad87872dedd32fae563c8a71539c4 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -124,13 +124,8 @@ class UserController $user['redirectedBaskets'] = RedirectBasketModel::getRedirectedBasketsByUserId(['userId' => $user['id']]); $user['history'] = HistoryModel::getByUserId(['userId' => $user['user_id'], 'select' => ['event_type', 'event_date', 'info', 'remote_ip']]); $user['canModifyPassword'] = false; - $user['canResetPassword'] = true; $user['canCreateMaarchParapheurUser'] = false; - $loggingMethod = CoreConfigModel::getLoggingMethod(); - if (in_array($loggingMethod['id'], self::ALTERNATIVES_CONNECTIONS_METHODS) && $user['loginmode'] != 'restMode') { - $user['canResetPassword'] = false; - } if ($user['loginmode'] == 'restMode') { $user['canModifyPassword'] = true; } @@ -549,22 +544,6 @@ class UserController return $response->withJson(['success' => 'success']); } - public function resetPassword(Request $request, Response $response, array $aArgs) - { - if (!PrivilegeController::hasPrivilege(['privilegeId' => 'manage_personal_data', 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); - } - - $error = $this->hasUsersRights(['id' => $aArgs['id']]); - if (!empty($error['error'])) { - return $response->withStatus($error['status'])->withJson(['errors' => $error['error']]); - } - - UserModel::resetPassword(['id' => $aArgs['id']]); - - return $response->withJson(['success' => 'success']); - } - public function updatePassword(Request $request, Response $response, array $aArgs) { $error = $this->hasUsersRights(['id' => $aArgs['id'], 'himself' => true]); @@ -1616,15 +1595,7 @@ class UserController return $response->withStatus(400)->withJson(['errors' => 'Password does not match security criteria']); } - UserModel::update([ - 'set' => [ - 'password' => AuthenticationModel::getPasswordHash($body['password']), - 'password_modification_date' => 'CURRENT_TIMESTAMP', - 'reset_token' => null - ], - 'where' => ['id = ?'], - 'data' => [$user['id']] - ]); + UserModel::resetPassword(['password' => $body['password'], 'id' => $user['id']]); $GLOBALS['id'] = $user['id']; diff --git a/src/app/user/models/UserModelAbstract.php b/src/app/user/models/UserModelAbstract.php index 234516f5c82cc5c26f46ecb46405daf626367970..2cec649bfe7cb7eded95912020559ce10f2eb30e 100755 --- a/src/app/user/models/UserModelAbstract.php +++ b/src/app/user/models/UserModelAbstract.php @@ -242,15 +242,16 @@ abstract class UserModelAbstract public static function resetPassword(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['id']); + ValidatorModel::notEmpty($aArgs, ['id', 'password']); ValidatorModel::intVal($aArgs, ['id']); DatabaseModel::update([ 'table' => 'users', 'set' => [ - 'password' => AuthenticationModel::getPasswordHash('maarch'), - 'change_password' => 'Y', - 'password_modification_date' => 'CURRENT_TIMESTAMP' + 'password' => AuthenticationModel::getPasswordHash($aArgs['password']), + 'change_password' => 'N', + 'password_modification_date' => 'CURRENT_TIMESTAMP', + 'reset_token' => null ], 'where' => ['id = ?'], 'data' => [$aArgs['id']] diff --git a/src/frontend/app/administration/user/user-administration.component.html b/src/frontend/app/administration/user/user-administration.component.html index 4abd402581954e4b286b1ca8e4fd14223d2dfa56..835a01c9c453aec3c5fb85ecf269769c1ec3597d 100755 --- a/src/frontend/app/administration/user/user-administration.component.html +++ b/src/frontend/app/administration/user/user-administration.component.html @@ -18,12 +18,6 @@ {{lang.desactivateAbsence}} </p> </a> - <a mat-list-item *ngIf="user.canResetPassword" (click)="resetPassword()"> - <mat-icon color="primary" mat-list-icon class="fa fa-key"></mat-icon> - <p mat-line> - {{lang.reinitPassword}} - </p> - </a> <a *ngIf="user.canModifyPassword" mat-list-item (click)="changePasswd();"> <mat-icon color="primary" mat-list-icon class="fa fa-key"></mat-icon> <p mat-line> diff --git a/src/frontend/app/administration/user/user-administration.component.ts b/src/frontend/app/administration/user/user-administration.component.ts index 819dd24ad2a055c6caf3b67247ce389c65ec96e8..74b340d251da6c9bfe23e32b8affe349a5c3fbe5 100755 --- a/src/frontend/app/administration/user/user-administration.component.ts +++ b/src/frontend/app/administration/user/user-administration.component.ts @@ -350,19 +350,6 @@ export class UserAdministrationComponent implements OnInit { this.selectedSignatureLabel = this.user.signatures[index].signature_label; } - resetPassword(user: any) { - let r = confirm(this.lang.confirmAction + ' ' + this.lang.resetPsw); - - if (r) { - this.http.post("../../rest/users/" + this.serialId + "/password", {}) - .subscribe((data: any) => { - this.notify.success(this.lang.pswReseted); - }, (err) => { - this.notify.error(err.error.errors); - }); - } - } - toggleGroup(group: any) { if ($j('#' + group.group_id + '-input').is(':checked') == true) { var groupReq = { diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 3611b0e47b6294eac093ecad4fe3609c3cf1cf0a..7282880a14cdbb90dbf96774620e53da32964c42 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -760,7 +760,6 @@ export const LANG_EN = { "redirectUserListInstances" : "Change of recipient for mail being processed", "redirectWhenAbscence" : "Redirect the basket to a user when bascence activation", "reference" : "Reference", - "reinitPassword" : "Reset password", "relatedBaskets" : "Related basket(s)", "relatedContactNumber" : "Number of contacts related", "relatedContacts" : "Related contacts", @@ -772,7 +771,6 @@ export const LANG_EN = { "reports" : "Reports", "requiredField" : "Required field", "resetColor" : "Reset color", - "resetPsw" : "Reset password", "resId" : "Res Identifier", "restrictedEntity" : "Restricted entity", "resultPage" : "Result page", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 031afebd1b086d5e6684ef6c3438288b510caa69..958d9f13641e0e8e0f890533ab97885de274ff7a 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -792,7 +792,6 @@ export const LANG_FR = { "redirectUserListInstances" : "Changement de destinataire pour les courriers en cours de traitement", "redirectWhenAbscence" : "Rediriger la bannette à une personne", "reference" : "Référence", - "reinitPassword" : "Réinitialiser le mot de passe", "relatedBaskets" : "Bannette(s) associée(s)", "relatedContactNumber" : "Contact(s) associé(s)", "relatedContacts" : "Contact(s) associé(s)", @@ -804,7 +803,6 @@ export const LANG_FR = { "reports" : "Statistiques", "requiredField" : "Champ requis", "resetColor" : "Réinitialiser la couleur", - "resetPsw" : "Réinitialiser le mot de passe", "resId" : "Identifiant GED", "restrictedEntity" : "Entité restreinte", "resultPage" : "Liste de résultats", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 4b40d3a09943523dd9307fc80ef4a777cfc59398..2a7253ebf12d7800ed58cf4adbb64324f091fbf8 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -788,7 +788,6 @@ export const LANG_NL = { "redirectUserListInstances" : "Change of recipient for mail being processed", //_TO_TRANSLATE_ "redirectWhenAbscence" : "Het bakje aan een persoon doorsturen", "reference" : "_TO_TRANSLATE", - "reinitPassword" : "Wachtwoord opnieuw instellen", "relatedBaskets" : "Gekoppeld(e) bakje(s)", "relatedContactNumber" : "Gekoppeld(e) contact(en)", "relatedContacts" : "Gekoppeld(e) contact(en)", @@ -800,7 +799,6 @@ export const LANG_NL = { "reports" : "Statistieken", "requiredField" : "Vereist veld", "resetColor" : "De kleur resetten", - "resetPsw" : "Wachtwoord opnieuw instellen", "resId" : "GED gebruikersnaam", "restrictedEntity" : "Restricted entity", //_TO_TRANSLATE "resultPage" : "Resultaatpagina",