From 2720c76e4d52db7b85733ceb008e3b05ec23f6b1 Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Tue, 9 Jan 2018 11:48:42 -0800 Subject: [PATCH] fix(password): do not let guests edit password when roles are enabled If config.enableUserRolesBasedOnToken is true, only let moderators and non-guests modify the password. Otherwise, only let moderators edit the password. --- .../invite/components/InviteDialog.web.js | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/react/features/invite/components/InviteDialog.web.js b/react/features/invite/components/InviteDialog.web.js index 73a6be1da..f657bdddc 100644 --- a/react/features/invite/components/InviteDialog.web.js +++ b/react/features/invite/components/InviteDialog.web.js @@ -27,6 +27,11 @@ class InviteDialog extends Component { * @static */ static propTypes = { + /** + * Whether or not the current user can modify the current password. + */ + _canEditPassword: PropTypes.bool, + /** * The redux store representation of the JitsiConference. */ @@ -37,11 +42,6 @@ class InviteDialog extends Component { */ _inviteURL: PropTypes.string, - /** - * Whether or not the current user is a conference moderator. - */ - _isModerator: PropTypes.bool, - /** * Invoked to obtain translated strings. */ @@ -64,7 +64,7 @@ class InviteDialog extends Component { * @returns {ReactElement} */ render() { - const { _conference, _inviteURL, t } = this.props; + const { _canEditPassword, _conference, _inviteURL, t } = this.props; const titleString = t('invite.inviteTo', { conferenceName: _conference.room }); @@ -80,7 +80,7 @@ class InviteDialog extends Component { conference = { _conference.conference } locked = { _conference.locked } password = { _conference.password } - showPasswordEdit = { this.props._isModerator } /> + showPasswordEdit = { _canEditPassword } /> ); @@ -94,17 +94,26 @@ class InviteDialog extends Component { * @param {Object} state - The Redux state. * @private * @returns {{ + * _canEditPassword: boolean, * _conference: Object, - * _inviteURL: string, - * _isModerator: boolean + * _inviteURL: string * }} */ function _mapStateToProps(state) { + const isModerator + = getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR; + let canEditPassword; + + if (state['features/base/config'].enableUserRolesBasedOnToken) { + canEditPassword = isModerator && !state['features/base/jwt'].isGuest; + } else { + canEditPassword = isModerator; + } + return { + _canEditPassword: canEditPassword, _conference: state['features/base/conference'], - _inviteURL: getInviteURL(state), - _isModerator: - getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR + _inviteURL: getInviteURL(state) }; }