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.
This commit is contained in:
Leonard Kim 2018-01-09 11:48:42 -08:00 committed by yanas
parent 4ab34589c8
commit 2720c76e4d
1 changed files with 21 additions and 12 deletions

View File

@ -27,6 +27,11 @@ class InviteDialog extends Component {
* @static * @static
*/ */
static propTypes = { static propTypes = {
/**
* Whether or not the current user can modify the current password.
*/
_canEditPassword: PropTypes.bool,
/** /**
* The redux store representation of the JitsiConference. * The redux store representation of the JitsiConference.
*/ */
@ -37,11 +42,6 @@ class InviteDialog extends Component {
*/ */
_inviteURL: PropTypes.string, _inviteURL: PropTypes.string,
/**
* Whether or not the current user is a conference moderator.
*/
_isModerator: PropTypes.bool,
/** /**
* Invoked to obtain translated strings. * Invoked to obtain translated strings.
*/ */
@ -64,7 +64,7 @@ class InviteDialog extends Component {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const { _conference, _inviteURL, t } = this.props; const { _canEditPassword, _conference, _inviteURL, t } = this.props;
const titleString const titleString
= t('invite.inviteTo', { conferenceName: _conference.room }); = t('invite.inviteTo', { conferenceName: _conference.room });
@ -80,7 +80,7 @@ class InviteDialog extends Component {
conference = { _conference.conference } conference = { _conference.conference }
locked = { _conference.locked } locked = { _conference.locked }
password = { _conference.password } password = { _conference.password }
showPasswordEdit = { this.props._isModerator } /> showPasswordEdit = { _canEditPassword } />
</div> </div>
</Dialog> </Dialog>
); );
@ -94,17 +94,26 @@ class InviteDialog extends Component {
* @param {Object} state - The Redux state. * @param {Object} state - The Redux state.
* @private * @private
* @returns {{ * @returns {{
* _canEditPassword: boolean,
* _conference: Object, * _conference: Object,
* _inviteURL: string, * _inviteURL: string
* _isModerator: boolean
* }} * }}
*/ */
function _mapStateToProps(state) { 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 { return {
_canEditPassword: canEditPassword,
_conference: state['features/base/conference'], _conference: state['features/base/conference'],
_inviteURL: getInviteURL(state), _inviteURL: getInviteURL(state)
_isModerator:
getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
}; };
} }