From 0d3781f3aae393ef28a32aabb70acc3121c0846d Mon Sep 17 00:00:00 2001 From: N Pex Date: Tue, 4 Apr 2023 14:30:50 +0000 Subject: [PATCH] Support authentication flows for login/register --- src/App.vue | 2 +- src/assets/config.json | 1 + src/assets/translations/en.json | 10 +- src/components/Chat.vue | 40 ++-- src/components/CreateRoom.vue | 99 +--------- src/components/InteractiveAuth.vue | 293 +++++++++++++++++++++++++++++ src/components/Join.vue | 6 +- src/components/Login.vue | 62 +++++- src/plugins/utils.js | 15 +- src/services/matrix.service.js | 88 +++++++-- src/store/index.js | 4 +- 11 files changed, 481 insertions(+), 139 deletions(-) create mode 100644 src/components/InteractiveAuth.vue diff --git a/src/App.vue b/src/App.vue index 2b1c114..d8e2ad3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -63,7 +63,7 @@ export default { }) .catch((error) => { console.log("Error creating client", error); - if (error.data.errcode ==='M_FORBIDDEN' && this.currentUser.is_guest) { + if (error.data && ((error.data.errcode ==='M_FORBIDDEN' && this.currentUser.is_guest) || error.data.errcode ==='M_USER_DEACTIVATED')) { // Guest account and password don't work. We are in a strange state, probably because // of server cleanup of accounts or similar. Wipe account and restart... this.$store.commit("setUser", null); diff --git a/src/assets/config.json b/src/assets/config.json index 1d12445..abc13bb 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -8,6 +8,7 @@ "languageSupportEmail": "support@guardianproject.info", "productLink": "letsconvene.im", "defaultServer": "https://neo.keanu.im", + "identityServer_unset": "", "rtl": false, "analytics": [ { diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index b7ce9d2..f237d9b 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -148,7 +148,15 @@ "login": "Login", "create_room": "Register & Create Room", "or": "OR", - "invalid_message": "Invalid username or password" + "invalid_message": "Invalid username or password", + "no_supported_flow": "The app can't login to the given server", + "terms": "The homeserver requires you to review and accept the following policies:", + "accept_terms": "Accept", + "email": "You need to verify you email address", + "send_verification": "Send verification email", + "sent_verification": "An email has been sent to {email}. Please use your regular email client to verify the address.", + "resend_verification": "Resend verification email", + "email_not_valid": "Email address not valid" }, "profile": { "title": "My Profile", diff --git a/src/components/Chat.vue b/src/components/Chat.vue index 3ec30c3..db1562e 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -322,6 +322,7 @@ export default { data() { return { + waitingForRoomObject: false, events: [], currentInput: "", typingMembers: [], @@ -419,7 +420,6 @@ export default { computed: { chatContainer() { const container = this.$refs.chatContainer; - console.log("GOT CONTAINER", container); if (this.useVoiceMode) { return container.$el; } @@ -547,6 +547,7 @@ export default { this.$matrix.off("Room.timeline", this.onEvent); this.$matrix.off("RoomMember.typing", this.onUserTyping); + this.waitingForRoomObject = false; this.events = []; this.timelineWindow = null; this.typingMembers = []; @@ -557,27 +558,32 @@ export default { this.stopRRTimer(); this.lastRR = null; - if (!this.room) { - // Public room? - if (this.roomId && this.roomId.startsWith("#")) { - this.onRoomNotJoined(); - } else if (this.roomId) { - this.onRoomNotJoined(); // Private room we are not joined to. What to do? We redirect to join - // screen, maybe the user has an invite already? - } + if (this.roomId) { + this.$matrix.isJoinedToRoom(this.roomId).then(joined => { + if (!joined) { + this.onRoomNotJoined(); + } else { + if (this.room) { + this.onRoomJoined(this.readMarker); + } else { + this.waitingForRoomObject = true; + return; // no room, wait for it (we know we are joined so need to wait for sync to complete) + } + } + }); + } else { this.initialLoadDone = true; return; // no room } - - // Joined? - if (this.room.hasMembershipState(this.currentUser.user_id, "join")) { - // Yes, load everything - this.onRoomJoined(this.readMarker); - } else { - this.onRoomNotJoined(); - } }, }, + room() { + // Were we waiting? + if (this.room && this.room.roomId == this.roomId && this.waitingForRoomObject) { + this.waitingForRoomObject = false; + this.onRoomJoined(this.readMarker); + } + }, showMessageOperations() { if (this.showMessageOperations) { this.$nextTick(() => { diff --git a/src/components/CreateRoom.vue b/src/components/CreateRoom.vue index ebf4288..c2324ad 100644 --- a/src/components/CreateRoom.vue +++ b/src/components/CreateRoom.vue @@ -39,8 +39,8 @@ background-color="white" v-on:keyup.enter="$refs.topic.focus()" :disabled="step > steps.INITIAL" autofocus solo @update:error="updateErrorState">
{{ $t("new_room.room_topic") }}
- +