From 30b76d372cc26289f5895bf0c7242ffc9400b7d4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 22 Mar 2016 12:58:12 +0000 Subject: [PATCH] Error messages for guests creating rooms --- src/components/structures/MatrixChat.js | 9 +++++++++ src/components/views/rooms/MemberInfo.js | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index c16b80ec62..459847ce88 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -464,9 +464,18 @@ module.exports = React.createClass({ //this.notifyNewScreen('new'); var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog"); var Loader = sdk.getComponent("elements.Spinner"); var modal = Modal.createDialog(Loader); + if (MatrixClientPeg.get().isGuest) { + Modal.createDialog(NeedToRegisterDialog, { + title: "Please Register", + description: "Guest users can't create new rooms. Please register to create room and start a chat." + }); + return; + } + // XXX: FIXME: deduplicate this with MemberInfo's 'start chat' impl MatrixClientPeg.get().createRoom({ preset: "private_chat", diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 196e3e4c5f..a79d90adbc 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -293,6 +293,16 @@ module.exports = React.createClass({ } else { self.setState({ creatingRoom: true }); + + if (MatrixClientPeg.get().isGuest()) { + var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog"); + Modal.createDialog(NeedToRegisterDialog, { + title: "Please Register", + description: "Guest users can't create new rooms. Please register to create room and start a chat." + }); + return; + } + MatrixClientPeg.get().createRoom({ // XXX: FIXME: deduplicate this with "view_create_room" in MatrixChat invite: [this.props.member.userId],