Don't try to make a request to get the totp status if its disabled
This commit is contained in:
parent
0720f644d0
commit
f10eaf9b28
1 changed files with 82 additions and 31 deletions
|
@ -1,5 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="loader-container" :class="{ 'is-loading': passwordUpdateService.loading || emailUpdateService.loading || totpService.loading }">
|
<div
|
||||||
|
class="loader-container"
|
||||||
|
:class="{ 'is-loading': passwordUpdateService.loading || emailUpdateService.loading || totpService.loading }">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<header class="card-header">
|
<header class="card-header">
|
||||||
<p class="card-header-title">
|
<p class="card-header-title">
|
||||||
|
@ -12,22 +14,37 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="newPassword">New Password</label>
|
<label class="label" for="newPassword">New Password</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="password" id="newPassword" placeholder="The new password..."
|
<input
|
||||||
v-model="passwordUpdate.newPassword" @keyup.enter="updatePassword"/>
|
class="input"
|
||||||
|
type="password"
|
||||||
|
id="newPassword"
|
||||||
|
placeholder="The new password..."
|
||||||
|
v-model="passwordUpdate.newPassword"
|
||||||
|
@keyup.enter="updatePassword"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="newPasswordConfirm">New Password Confirmation</label>
|
<label class="label" for="newPasswordConfirm">New Password Confirmation</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="password" id="newPasswordConfirm" placeholder="Confirm your new password..."
|
<input
|
||||||
v-model="passwordConfirm" @keyup.enter="updatePassword"/>
|
class="input"
|
||||||
|
type="password"
|
||||||
|
id="newPasswordConfirm"
|
||||||
|
placeholder="Confirm your new password..."
|
||||||
|
v-model="passwordConfirm"
|
||||||
|
@keyup.enter="updatePassword"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="currentPassword">Current Password</label>
|
<label class="label" for="currentPassword">Current Password</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="password" id="currentPassword" placeholder="Your current password"
|
<input
|
||||||
v-model="passwordUpdate.oldPassword" @keyup.enter="updatePassword"/>
|
class="input"
|
||||||
|
type="password"
|
||||||
|
id="currentPassword"
|
||||||
|
placeholder="Your current password"
|
||||||
|
v-model="passwordUpdate.oldPassword"
|
||||||
|
@keyup.enter="updatePassword"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -53,15 +70,25 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="newEmail">New Email Address</label>
|
<label class="label" for="newEmail">New Email Address</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="email" id="newEmail" placeholder="The new email address..."
|
<input
|
||||||
v-model="emailUpdate.newEmail" @keyup.enter="updateEmail"/>
|
class="input"
|
||||||
|
type="email"
|
||||||
|
id="newEmail"
|
||||||
|
placeholder="The new email address..."
|
||||||
|
v-model="emailUpdate.newEmail"
|
||||||
|
@keyup.enter="updateEmail"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="currentPassword">Current Password</label>
|
<label class="label" for="currentPassword">Current Password</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="password" id="currentPassword" placeholder="Your current password"
|
<input
|
||||||
v-model="emailUpdate.password" @keyup.enter="updateEmail"/>
|
class="input"
|
||||||
|
type="password"
|
||||||
|
id="currentPassword"
|
||||||
|
placeholder="Your current password"
|
||||||
|
v-model="emailUpdate.password"
|
||||||
|
@keyup.enter="updateEmail"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -82,10 +109,17 @@
|
||||||
</p>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<a class="button is-primary" v-if="!totpEnrolled && totp.secret === ''" @click="totpEnroll()" :class="{ 'is-loading': totpService.loading }">Enroll</a>
|
<a
|
||||||
|
class="button is-primary"
|
||||||
|
v-if="!totpEnrolled && totp.secret === ''"
|
||||||
|
@click="totpEnroll()"
|
||||||
|
:class="{ 'is-loading': totpService.loading }">
|
||||||
|
Enroll
|
||||||
|
</a>
|
||||||
<div class="content" v-else-if="totp.secret !== '' && !totp.enabled">
|
<div class="content" v-else-if="totp.secret !== '' && !totp.enabled">
|
||||||
<p>
|
<p>
|
||||||
To finish your setup, use this secret in your totp app (Google Authenticator or similar): <strong>{{ totp.secret }}</strong><br/>
|
To finish your setup, use this secret in your totp app (Google Authenticator or similar):
|
||||||
|
<strong>{{ totp.secret }}</strong><br/>
|
||||||
After that, enter a code from your app below.
|
After that, enter a code from your app below.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -95,8 +129,13 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="totpConfirmPasscode">Passcode</label>
|
<label class="label" for="totpConfirmPasscode">Passcode</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" id="totpConfirmPasscode" placeholder="A code generated by your totp application"
|
<input
|
||||||
v-model="totpConfirmPasscode" @keyup.enter="totpConfirm()"/>
|
class="input"
|
||||||
|
type="text"
|
||||||
|
id="totpConfirmPasscode"
|
||||||
|
placeholder="A code generated by your totp application"
|
||||||
|
v-model="totpConfirmPasscode"
|
||||||
|
@keyup.enter="totpConfirm()"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="button is-primary" @click="totpConfirm()">Confirm</a>
|
<a class="button is-primary" @click="totpConfirm()">Confirm</a>
|
||||||
|
@ -112,8 +151,14 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="currentPassword">Please Enter Your Password</label>
|
<label class="label" for="currentPassword">Please Enter Your Password</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="password" id="currentPassword" placeholder="Your current password"
|
<input
|
||||||
v-model="totpDisablePassword" @keyup.enter="totpDisable" v-focus/>
|
class="input"
|
||||||
|
type="password"
|
||||||
|
id="currentPassword"
|
||||||
|
placeholder="Your current password"
|
||||||
|
v-model="totpDisablePassword"
|
||||||
|
@keyup.enter="totpDisable"
|
||||||
|
v-focus/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="button is-danger" @click="totpDisable()">Disable two factor authentication</a>
|
<a class="button is-danger" @click="totpDisable()">Disable two factor authentication</a>
|
||||||
|
@ -164,20 +209,7 @@
|
||||||
this.totpService = new TotpService()
|
this.totpService = new TotpService()
|
||||||
this.totp = new TotpModel()
|
this.totp = new TotpModel()
|
||||||
|
|
||||||
this.totpService.get()
|
this.totpStatus()
|
||||||
.then(r => {
|
|
||||||
this.$set(this, 'totp', r)
|
|
||||||
this.totpSetQrCode()
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
// Error code 1016 means totp is not enabled, we don't need an error in that case.
|
|
||||||
if (e.response && e.response.data && e.response.data.code && e.response.data.code === 1016) {
|
|
||||||
this.totpEnrolled = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.error(e, this)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
computed: mapState({
|
computed: mapState({
|
||||||
totpEnabled: state => state.config.totpEnabled
|
totpEnabled: state => state.config.totpEnabled
|
||||||
|
@ -202,6 +234,25 @@
|
||||||
})
|
})
|
||||||
.catch(e => this.error(e, this))
|
.catch(e => this.error(e, this))
|
||||||
},
|
},
|
||||||
|
totpStatus() {
|
||||||
|
if (!this.totpEnabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.totpService.get()
|
||||||
|
.then(r => {
|
||||||
|
this.$set(this, 'totp', r)
|
||||||
|
this.totpSetQrCode()
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
// Error code 1016 means totp is not enabled, we don't need an error in that case.
|
||||||
|
if (e.response && e.response.data && e.response.data.code && e.response.data.code === 1016) {
|
||||||
|
this.totpEnrolled = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.error(e, this)
|
||||||
|
})
|
||||||
|
},
|
||||||
totpSetQrCode() {
|
totpSetQrCode() {
|
||||||
this.totpService.qrcode()
|
this.totpService.qrcode()
|
||||||
.then(qr => {
|
.then(qr => {
|
||||||
|
|
Loading…
Reference in a new issue