assets/js/store/modules/user.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 26
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 5
mnd 0
bc 0
fnc 5
bpm 0
cpm 1
noi 0
1
import userApi from '../../api/user'
2
3
export default {
4
    namespaced: true,
5
    state : {
6
        user: {},
7
    },
8
    getters: {
9
        'hasRole':  (state) => (role) => {
10
            return state.user.roles && state.user.roles.includes(role);
11
        }
12
    },
13
    actions: {
14
        'load': ({commit}) => {
15
            userApi.me().then(function (response) {
16
                commit('setUser', response.data);
17
            });
18
        }
19
    },
20
21
    mutations: {
22
        'setUser': (state, value) => {
23
            state.user = value;
24
        },
25
    }
26
}
27