Skip to content
Snippets Groups Projects
Verified Commit 3d3175f3 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fix #606: Refresh profile after user settings update to avoid cache issues

parent 6458a748
No related branches found
No related tags found
No related merge requests found
Refresh profile after user settings update to avoid cache issues (#606)
...@@ -170,6 +170,9 @@ export default { ...@@ -170,6 +170,9 @@ export default {
return axios.patch(url, payload).then(response => { return axios.patch(url, payload).then(response => {
logger.default.info('Updated settings successfully') logger.default.info('Updated settings successfully')
self.settings.success = true self.settings.success = true
return axios.get('users/users/me/').then((response) => {
self.$store.dispatch('auth/updateProfile', response.data)
})
}, error => { }, error => {
logger.default.error('Error while updating settings') logger.default.error('Error while updating settings')
self.isLoading = false self.isLoading = false
......
...@@ -119,22 +119,27 @@ export default { ...@@ -119,22 +119,27 @@ export default {
return axios.get('users/users/me/').then((response) => { return axios.get('users/users/me/').then((response) => {
logger.default.info('Successfully fetched user profile') logger.default.info('Successfully fetched user profile')
let data = response.data dispatch('updateProfile', response.data)
commit('authenticated', true)
commit('profile', data)
commit('username', data.username)
dispatch('ui/fetchUnreadNotifications', null, { root: true }) dispatch('ui/fetchUnreadNotifications', null, { root: true })
dispatch('favorites/fetch', null, { root: true }) dispatch('favorites/fetch', null, { root: true })
dispatch('playlists/fetchOwn', null, { root: true }) dispatch('playlists/fetchOwn', null, { root: true })
Object.keys(data.permissions).forEach(function (key) {
// this makes it easier to check for permissions in templates
commit('permission', {key, status: data.permissions[String(key)]})
})
return response.data return response.data
}, (response) => { }, (response) => {
logger.default.info('Error while fetching user profile') logger.default.info('Error while fetching user profile')
}) })
}, },
updateProfile({ commit }, data) {
commit("authenticated", true)
commit("profile", data)
commit("username", data.username)
Object.keys(data.permissions).forEach(function(key) {
// this makes it easier to check for permissions in templates
commit("permission", {
key,
status: data.permissions[String(key)]
})
})
},
refreshToken ({commit, dispatch, state}) { refreshToken ({commit, dispatch, state}) {
return axios.post('token/refresh/', {token: state.token}).then(response => { return axios.post('token/refresh/', {token: state.token}).then(response => {
logger.default.info('Refreshed auth token') logger.default.info('Refreshed auth token')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment