Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 26 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 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 |