| 123456789101112131415161718192021222324252627282930313233343536 |
- import VuexORM from '@vuex-orm/core'
- const cookieparser = process.server ? require('cookieparser') : undefined
- export const plugins = [
- VuexORM.install()
- ];
- export const actions = {
- async nuxtServerInit({commit, dispatch}, {req}) {
- let bearer = null
- let accessId = null
- if (req.headers.cookie) {
- const parsed = cookieparser.parse(req.headers.cookie)
- try {
- bearer = parsed.BEARER
- } catch (err) {
- // No valid cookie found
- }
- try {
- accessId = parsed.AccessId
- } catch (err) {
- // No valid Access Id found
- }
- }
- commit('profile/access/setBearer', bearer)
- commit('profile/access/setAccessId', accessId)
- await dispatch('updateProfile')
- },
- async updateProfile({dispatch, state}) {
- const my_profile = await this.$http.$get(`/api/my_profile/${state.profile.access.accessId}`)
- dispatch('profile/access/setProfile', my_profile)
- },
- }
|