From e881f18e3147395b99f2741c02fb3bb037a070ba Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Thu, 14 Dec 2023 12:03:33 +0100 Subject: [PATCH] [New #49] Handling user management with keycloak Resolves #12 --- js/components/user/User.js | 63 +++++++++++++--------------- js/components/user/UserController.js | 1 + 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/js/components/user/User.js b/js/components/user/User.js index a1c6a0e1..a47574eb 100644 --- a/js/components/user/User.js +++ b/js/components/user/User.js @@ -89,33 +89,23 @@ class User extends React.Component { }); }; - _passwordChangeButton() { + _passwordChange() { const {user, currentUser, handlers} = this.props; - if (isUsingOidcAuth()) { - return null; - } if (user.isNew || (currentUser.username !== user.username && currentUser.role !== ROLE.ADMIN)) { return null; } else { return ; + onClick={handlers.onPasswordChange}>{this.i18n('user.password-change')}; } } - _externalEditUserButton() { + _redirectToKeycloak() { const {user, currentUser, handlers} = this.props; - if (!isUsingOidcAuth()) { - return null; - } if (user.isNew || (currentUser.username !== user.username && currentUser.role !== ROLE.ADMIN)) { return null; } else { return ; + onClick={handlers.onKeycloakRedirect}>{this.i18n('user.edit')}; } } @@ -212,13 +202,15 @@ class User extends React.Component {
@@ -226,14 +218,14 @@ class User extends React.Component {
@@ -254,8 +246,8 @@ class User extends React.Component {
{this._generateRolesOptions()} @@ -272,20 +264,21 @@ class User extends React.Component { }
{this._impersonateButton()} - {this._passwordChangeButton()} - {this._externalEditUserButton()} - {!isUsingOidcAuth() && this._saveAndSendEmailButton()} - {(currentUser.role === ROLE.ADMIN || currentUser.username === user.username) && - + {isUsingOidcAuth() ? + this._redirectToKeycloak() : + this._passwordChange()} + {this._saveAndSendEmailButton()} + {(currentUser.role === ROLE.ADMIN || currentUser.username === user.username) && + }