{"size": 977, "ext": "js", "max_stars_repo_path": "front_end/ProTJec_frontend/src/utils/jwt.js", "max_stars_repo_name": "skyleaworlder/ProTJec", "max_stars_repo_stars_event_min_datetime": "2020-05-29T13:24:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-10T13:45:06.000Z", "max_issues_repo_path": "front_end/ProTJec_frontend/src/utils/jwt.js", "max_issues_repo_name": "skyleaworlder/ProTJec", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "front_end/ProTJec_frontend/src/utils/jwt.js", "max_forks_repo_name": "skyleaworlder/ProTJec", "max_forks_repo_forks_event_min_datetime": "2021-01-28T11:26:58.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-28T11:26:58.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 23.8292682927, "max_line_length": 62, "alphanum_fraction": 0.6120777892}
// used in store/modules/user.js

export function getJwtPayload(jwt) {
  console.log(jwt)
  var indexOfDot = jwt.indexOf('.')
  var tmp = jwt.substring(indexOfDot + 1, jwt.length - 1)
  console.log(tmp, indexOfDot)
  indexOfDot = tmp.indexOf('.')
  var payload = tmp.substring(0, indexOfDot)
  console.log(payload, indexOfDot, tmp, "hahah")
  return window.atob(payload)
}

/**
   *
   userInfo format:
   {
    "user_name": "admin",
    "scope": [
      "read",
      "write"
    ],
    "exp": 1576826361,
    "authorities": [
      "AUTH_USER",
      "AUTH_ADMIN"
    ],
    "jti": "61aab180-0286-4139-b598-386508c938ed",
    "tenant": 1,
    "client_id": "client"
  }
   * @param {*} jwt
   */
export function getUserInfo(jwt) {
  const jwtPayload = getJwtPayload(jwt)
  // console.log(jwtPayload)
  // alert(JSON.stringify(jwtPayload));
  // TODO:改为，如果尚未存入sessionStorage，先将解码之后的用户信息存入sessionStorage
  return JSON.parse(jwtPayload)
}
