authority.js 565 Bytes
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2
// use localStorage to store the authority info, which might be sent from server in actual project.
export function getAuthority() {
3
  // return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
afc163's avatar
afc163 committed
4 5 6 7 8 9
  const authorityString = localStorage.getItem('antd-pro-authority');
  let authority;
  try {
    authority = JSON.parse(authorityString);
  } catch (e) {
    authority = [authorityString];
10
  }
afc163's avatar
afc163 committed
11
  return authority || ['admin'];
ddcat1115's avatar
ddcat1115 committed
12 13 14
}

export function setAuthority(authority) {
rongxingsun's avatar
rongxingsun committed
15
  return localStorage.setItem('antd-pro-authority', JSON.stringify(authority));
ddcat1115's avatar
ddcat1115 committed
16
}