User account deletion (#651)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/651 Co-authored-by: konrad <konrad@kola-entertainments.de> Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -181,27 +181,8 @@ export default {
|
||||
ctx.commit('info', info)
|
||||
|
||||
if (authenticated) {
|
||||
const HTTP = HTTPFactory()
|
||||
// We're not returning the promise here to prevent blocking the initial ui render if the user is
|
||||
// accessing the site with a token in local storage
|
||||
HTTP.get('user', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${jwt}`,
|
||||
},
|
||||
})
|
||||
.then(r => {
|
||||
const info = new UserModel(r.data)
|
||||
info.type = ctx.state.info.type
|
||||
info.email = ctx.state.info.email
|
||||
info.exp = ctx.state.info.exp
|
||||
|
||||
ctx.commit('info', info)
|
||||
ctx.commit('authenticated', authenticated)
|
||||
ctx.commit('lastUserRefresh')
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Error while refreshing user info:', e)
|
||||
})
|
||||
ctx.dispatch('refreshUserInfo')
|
||||
ctx.commit('authenticated', authenticated)
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +193,33 @@ export default {
|
||||
|
||||
return Promise.resolve()
|
||||
},
|
||||
refreshUserInfo(ctx) {
|
||||
const jwt = getToken()
|
||||
if (!jwt) {
|
||||
return
|
||||
}
|
||||
|
||||
const HTTP = HTTPFactory()
|
||||
// We're not returning the promise here to prevent blocking the initial ui render if the user is
|
||||
// accessing the site with a token in local storage
|
||||
HTTP.get('user', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${jwt}`,
|
||||
},
|
||||
})
|
||||
.then(r => {
|
||||
const info = new UserModel(r.data)
|
||||
info.type = ctx.state.info.type
|
||||
info.email = ctx.state.info.email
|
||||
info.exp = ctx.state.info.exp
|
||||
|
||||
ctx.commit('info', info)
|
||||
ctx.commit('lastUserRefresh')
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Error while refreshing user info:', e)
|
||||
})
|
||||
},
|
||||
// Renews the api token and saves it to local storage
|
||||
renewToken(ctx) {
|
||||
// Timeout to avoid race conditions when authenticated as a user (=auth token in localStorage) and as a
|
||||
|
@ -23,6 +23,7 @@ export default {
|
||||
privacyPolicyUrl: '',
|
||||
},
|
||||
caldavEnabled: false,
|
||||
userDeletionEnabled: true,
|
||||
auth: {
|
||||
local: {
|
||||
enabled: true,
|
||||
@ -49,6 +50,7 @@ export default {
|
||||
state.legal.imprintUrl = config.legal.imprint_url
|
||||
state.legal.privacyPolicyUrl = config.legal.privacy_policy_url
|
||||
state.caldavEnabled = config.caldav_enabled
|
||||
state.userDeletionEnabled = config.user_deletion_enabled
|
||||
const auth = objectToCamelCase(config.auth)
|
||||
state.auth.local.enabled = auth.local.enabled
|
||||
state.auth.openidConnect.enabled = auth.openidConnect.enabled
|
||||
|
Reference in New Issue
Block a user