Resolve "Set Password should be changed to Change Password once the user has set the password on User Profile screen"

This commit is contained in:
N Pex 2023-06-07 12:55:12 +00:00
parent 026a422230
commit 7b3b167afe
5 changed files with 17 additions and 48 deletions

View file

@ -428,10 +428,7 @@ export default {
console.log( console.log(
"CreateRoom: Set display name to: " + this.selectedProfile.name "CreateRoom: Set display name to: " + this.selectedProfile.name
); );
return this.$matrix.matrixClient.setDisplayName( return this.$matrix.setUserDisplayName(this.selectedProfile.name);
this.selectedProfile.name,
undefined
);
} }
}.bind(this) }.bind(this)
) )

View file

@ -371,7 +371,7 @@ export default {
return Promise.resolve(user); return Promise.resolve(user);
} else { } else {
console.log("Join: Set display name to: " + this.selectedProfile.name); console.log("Join: Set display name to: " + this.selectedProfile.name);
return this.$matrix.matrixClient.setDisplayName(this.selectedProfile.name, undefined); return this.$matrix.setUserDisplayName(this.selectedProfile.name);
} }
}.bind(this) }.bind(this)
) )

View file

@ -69,7 +69,7 @@
<ActionRow <ActionRow
@click="showEditPasswordDialog = true" @click="showEditPasswordDialog = true"
:icon="'$vuetify.icons.password'" :icon="'$vuetify.icons.password'"
:text="$t('profile.set_password')" :text="$matrix.currentUser.is_guest ? $t('profile.set_password') : $t('profile.change_password')"
/> />
<ActionRow <ActionRow
@click=" @click="
@ -93,7 +93,7 @@
:width="$vuetify.breakpoint.smAndUp ? '940px' : '80%'" :width="$vuetify.breakpoint.smAndUp ? '940px' : '80%'"
> >
<v-card :disabled="settingPassword"> <v-card :disabled="settingPassword">
<v-card-title>{{ $t("profile.change_password") }}</v-card-title> <v-card-title>{{ $matrix.currentUser.is_guest ? $t("profile.set_password") : $t("profile.change_password") }}</v-card-title>
<v-card-text> <v-card-text>
<v-text-field <v-text-field
v-if="!$matrix.currentUser.is_guest" v-if="!$matrix.currentUser.is_guest"
@ -232,42 +232,6 @@ export default {
}, },
computed: { computed: {
user() {
if (!this.$matrix.matrixClient) {
return null;
}
return this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
},
displayName() {
if (!this.user) {
return null;
}
return this.user.displayName || this.user.userId;
},
userAvatar() {
if (!this.user || !this.user.avatarUrl) {
return null;
}
return this.$matrix.matrixClient.mxcUrlToHttp(
this.user.avatarUrl,
80,
80,
"scale",
true
);
},
userAvatarLetter() {
if (!this.user) {
return null;
}
return (this.user.displayName || this.user.userId.substring(1))
.substring(0, 1)
.toUpperCase();
},
passwordsMatch() { passwordsMatch() {
return ( return (
!this.newPasswordHasError && !this.newPasswordHasError &&

View file

@ -12,7 +12,7 @@ export default {
if (!this.user) { if (!this.user) {
return null; return null;
} }
return this.user.displayName; return this.$matrix.userDisplayName || this.user.displayName;
}, },
set(newValue) { set(newValue) {
this.user.displayName = newValue this.user.displayName = newValue
@ -20,17 +20,17 @@ export default {
}, },
userAvatar() { userAvatar() {
if (!this.user || !this.user.avatarUrl) { if (!this.$matrix.userAvatar) {
return null; return null;
} }
return this.$matrix.matrixClient.mxcUrlToHttp(this.user.avatarUrl, 80, 80, 'scale', true); return this.$matrix.matrixClient.mxcUrlToHttp(this.$matrix.userAvatar, 80, 80, 'scale', true);
}, },
userAvatarLetter() { userAvatarLetter() {
if (!this.user) { if (!this.user) {
return null; return null;
} }
return (this.user.displayName || this.user.userId.substring(1)).substring(0, 1).toUpperCase(); return (this.$matrix.userDisplayName || this.user.displayName || this.user.userId.substring(1)).substring(0, 1).toUpperCase();
}, },
passwordsMatch() { passwordsMatch() {
@ -46,7 +46,7 @@ export default {
}) })
}, },
updateDisplayName(name) { updateDisplayName(name) {
this.$matrix.matrixClient.setDisplayName(name || this.user.userId); this.$matrix.setUserDisplayName(name || this.user.userId);
} }
} }
} }

View file

@ -946,6 +946,14 @@ export default {
} }
}, },
setUserDisplayName(name) {
if (this.matrixClient) {
return this.matrixClient.setDisplayName(name || this.user.userId).then(() => this.userDisplayName = name).catch(err => console.err("Failed to set display name", err));
} else {
return Promise.reject("No matrix client");
}
},
setPassword(oldPassword, newPassword) { setPassword(oldPassword, newPassword) {
if (this.matrixClient && this.currentUser) { if (this.matrixClient && this.currentUser) {
const authDict = { const authDict = {