Add change password (Preferences > Change Password)

This commit is contained in:
2026-05-25 08:44:15 +02:00
parent ed4d0b261f
commit 55a9ae816f
3 changed files with 55 additions and 0 deletions
+26
View File
@@ -164,6 +164,16 @@
</select>
</div>
<h3>Change Password</h3>
<div class="panel-section">
<form @submit.prevent="changePassword" class="admin-form">
<input v-model="pwCurrent" type="password" placeholder="Current password" required />
<input v-model="pwNew" type="password" placeholder="New password" required />
<button type="submit">Change</button>
</form>
<p v-if="pwMsg" class="admin-msg">{{ pwMsg }}</p>
</div>
<h3>Two-Factor Authentication</h3>
<div class="panel-section" v-if="!totpEnabled">
<button @click="setupTOTP" class="action-btn">Enable 2FA</button>
@@ -293,6 +303,11 @@ const totpUri = ref('')
const totpSecret = ref('')
const totpCode = ref('')
// Password change
const pwCurrent = ref('')
const pwNew = ref('')
const pwMsg = ref('')
// Git remotes
const gitRemotes = ref([])
const newRemote = ref({ name: '', url: '' })
@@ -527,6 +542,17 @@ function applyThemeFromPrefs() {
savePrefs()
}
async function changePassword() {
try {
await api('/api/auth/change-password', { current_password: pwCurrent.value, new_password: pwNew.value })
pwMsg.value = 'Password changed successfully'
pwCurrent.value = ''
pwNew.value = ''
} catch (e) {
pwMsg.value = 'Failed — check current password'
}
}
// ─── TOTP ────────────────────────────────────────────────────────────────────
async function setupTOTP() {