Merge branch '310-handle-account-errors-better-on-call-to-createroom' into 'dev'

Wipe guest accounts on password errors

See merge request keanuapp/keanuapp-weblite!77
This commit is contained in:
N Pex 2022-04-21 09:41:52 +00:00
commit ecfde40147
3 changed files with 19 additions and 2 deletions

View file

@ -63,6 +63,13 @@ export default {
})
.catch((error) => {
console.log("Error creating client", error);
if (error.data.errcode ==='M_FORBIDDEN' && this.currentUser.is_guest) {
// 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);
this.$store.commit("setCurrentRoomId", null);
this.$navigation.push({ path: "/login" }, -1);
}
})
.finally(() => {
this.loading = false;

View file

@ -787,6 +787,7 @@ export default {
this.timelineWindow = null;
this.typingMembers = [];
this.initialLoadDone = false;
this.showCreatedRoomWelcomeHeader = false;
// Stop RR timer
this.stopRRTimer();

View file

@ -409,12 +409,21 @@ export default {
// we need to hang on to the generated password and use that to login to a new
// session, so only wipe the token in s that case.
// Clear the access token
var user = JSON.parse(this.$store.state.auth.user);
var user = this.$store.state.auth.user;
if (user.is_guest) {
delete user.access_token;
this.$store.commit("setUser", user);
// Login again
this.login(user);
this.login(user).catch(error => {
if (error.data.errcode ==='M_FORBIDDEN' && this.currentUser.is_guest) {
// 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);
}
this.$store.commit("setCurrentRoomId", null);
this.$navigation.push({ path: "/login" }, -1);
})
} else {
this.$store.commit("setUser", null);
this.$store.commit("setCurrentRoomId", null);