export const USER_MAP_LOCAL = [
  {
    name: 'super_admin',
    password:'123',
    token: 'super_admin',
  },
  {
    name: 'admin',
    password:'321',
    token: 'admin',
  },
];
export const  USER_MAP_REGISTER = [
  {
    name: 'test',
    password:'test',
    token: 'test',
  },
]


export const login = req => {
  req = JSON.parse(req.body)
  console.log(req)
  const localUserInfo = req.localUserInfo
  console.log(localUserInfo)
  let localUserInfoTemp = {name:'',password:'',token:'',flag:false}
  for(let i=0;i<localUserInfo.length;i++){
    console.log(localUserInfo[i])
    if(localUserInfo[i].name === req.userName){
      if(localUserInfo[i].password === req.password){
            localUserInfoTemp.name=req.userName,
            localUserInfoTemp.password=req.password,
            localUserInfoTemp.token=localUserInfo[i].token,
            localUserInfoTemp.flag=true
        break;
      }else{
        localUserInfoTemp.password = '密码名错误'
      }
    }else{
      localUserInfoTemp.name = '用户名错误'
    }
  }
    return localUserInfoTemp;

}

export const loginOut = req =>{
return req;
}

















export const getUserInfo = req => {
  const params = getParams(req.url)
  return USER_MAP[params.token]
}

export const logout = req => {
  return null
}
