Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(LocalStorageCookiesSvc): add getInfoFromJWT
Browse files Browse the repository at this point in the history
feat(LocalStorageCookiesSvc): add `getInfoFromJWT ` (jwt decode)
  • Loading branch information
Metnew committed Sep 17, 2017
1 parent 5a2d4c3 commit bea8213
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/api/LocalStorageCookiesSvc/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import * as store from 'store2'
import Cookies from 'js-cookie'
import decodeJWT from 'jwt-decode'

export const JWT_TOKEN = 'JWT_TOKEN'

Expand All @@ -18,4 +19,9 @@ export function setLocalToken (token: string) {
Cookies.set(JWT_TOKEN, token, {expires: 365})
}

export function getInfoFromJWT () {
const token = getLocalToken()
return decodeJWT(token)
}

export const isLoggedIn = () => !!getLocalToken()

0 comments on commit bea8213

Please sign in to comment.