Refactor success and error messages
This commit is contained in:
@ -82,7 +82,9 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div v-if="hasApiUrl && openidConnect.enabled && openidConnect.providers && openidConnect.providers.length > 0" class="mt-4">
|
||||
<div
|
||||
v-if="hasApiUrl && openidConnect.enabled && openidConnect.providers && openidConnect.providers.length > 0"
|
||||
class="mt-4">
|
||||
<x-button
|
||||
@click="redirectToProvider(p)"
|
||||
v-for="(p, k) in openidConnect.providers"
|
||||
@ -104,7 +106,6 @@ import {mapState} from 'vuex'
|
||||
|
||||
import router from '../../router'
|
||||
import {HTTPFactory} from '@/http-common'
|
||||
import message from '../../message'
|
||||
import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types'
|
||||
import legal from '../../components/misc/legal'
|
||||
import ApiConfig from '@/components/misc/api-config'
|
||||
@ -126,7 +127,7 @@ export default {
|
||||
// FIXME: Why is this here? Can we find a better place for this?
|
||||
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
|
||||
if (emailVerifyToken) {
|
||||
const cancel = message.setLoading(this)
|
||||
const cancel = this.setLoading()
|
||||
HTTP.post(`user/confirm`, {token: emailVerifyToken})
|
||||
.then(() => {
|
||||
localStorage.removeItem('emailConfirmToken')
|
||||
@ -158,6 +159,15 @@ export default {
|
||||
openidConnect: state => state.config.auth.openidConnect,
|
||||
}),
|
||||
methods: {
|
||||
setLoading() {
|
||||
const timeout = setTimeout(() => {
|
||||
this.loading = true
|
||||
}, 100)
|
||||
return () => {
|
||||
clearTimeout(timeout)
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
this.$store.commit(ERROR_MESSAGE, '')
|
||||
// Some browsers prevent Vue bindings from working with autofilled values.
|
||||
@ -173,7 +183,8 @@ export default {
|
||||
}
|
||||
|
||||
this.$store.dispatch('auth/login', credentials)
|
||||
.catch(() => {})
|
||||
.catch(() => {
|
||||
})
|
||||
},
|
||||
redirectToProvider(provider) {
|
||||
const state = Math.random().toString(36).substring(2, 24)
|
||||
|
@ -338,22 +338,22 @@ export default {
|
||||
methods: {
|
||||
updatePassword() {
|
||||
if (this.passwordConfirm !== this.passwordUpdate.newPassword) {
|
||||
this.error({message: 'The new password and its confirmation don\'t match.'}, this)
|
||||
this.error({message: 'The new password and its confirmation don\'t match.'})
|
||||
return
|
||||
}
|
||||
|
||||
this.passwordUpdateService.update(this.passwordUpdate)
|
||||
.then(() => {
|
||||
this.success({message: 'The password was successfully updated.'}, this)
|
||||
this.success({message: 'The password was successfully updated.'})
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
updateEmail() {
|
||||
this.emailUpdateService.update(this.emailUpdate)
|
||||
.then(() => {
|
||||
this.success({message: 'Your email address was successfully updated. We\'ve sent you a link to confirm it.'}, this)
|
||||
this.success({message: 'Your email address was successfully updated. We\'ve sent you a link to confirm it.'})
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
totpStatus() {
|
||||
if (!this.totpEnabled) {
|
||||
@ -371,7 +371,7 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
this.error(e, this)
|
||||
this.error(e)
|
||||
})
|
||||
},
|
||||
totpSetQrCode() {
|
||||
@ -388,24 +388,24 @@ export default {
|
||||
this.$set(this, 'totp', r)
|
||||
this.totpSetQrCode()
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
totpConfirm() {
|
||||
this.totpService.enable({passcode: this.totpConfirmPasscode})
|
||||
.then(() => {
|
||||
this.$set(this.totp, 'enabled', true)
|
||||
this.success({message: 'You\'ve successfully confirmed your totp setup and can use it from now on!'}, this)
|
||||
this.success({message: 'You\'ve successfully confirmed your totp setup and can use it from now on!'})
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
totpDisable() {
|
||||
this.totpService.disable({password: this.totpDisablePassword})
|
||||
.then(() => {
|
||||
this.totpEnrolled = false
|
||||
this.$set(this, 'totp', new TotpModel())
|
||||
this.success({message: 'Two factor authentication was sucessfully disabled.'}, this)
|
||||
this.success({message: 'Two factor authentication was sucessfully disabled.'})
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
updateSettings() {
|
||||
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
|
||||
@ -413,9 +413,9 @@ export default {
|
||||
this.userSettingsService.update(this.settings)
|
||||
.then(() => {
|
||||
this.$store.commit('auth/setUserSettings', this.settings)
|
||||
this.success({message: 'The name was successfully changed.'}, this)
|
||||
this.success({message: 'The name was successfully changed.'})
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
.catch(e => this.error(e))
|
||||
},
|
||||
copy(text) {
|
||||
copy(text)
|
||||
|
Reference in New Issue
Block a user