Skip to content

Commit

Permalink
[SDPSUP-668] Ignore null cookie for auth content.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly committed Aug 9, 2019
1 parent 7d658e3 commit 78816bd
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Cookie from 'js-cookie'
import { isPreviewPath } from './preview'

const authCookieName = 'authenticatedContent'

const nullValue = '{"tideAuthenticatedContent":{"token":null}}'
/**
* Decode a JWT token and test exipration date.
* @param {String} token JWT token
* @return {Boolean} is expired
*/
function isTokenExpired (token) {
if (token) {
if (token && token !== nullValue) {
const jwtDecode = require('jwt-decode')
const { exp } = jwtDecode(token)
// Token expiry timestamp is in a shorter format, match them for comparison
Expand Down Expand Up @@ -61,7 +61,11 @@ function clientClearToken (store) {
function serverGetToken (serverCookie) {
if (serverCookie) {
const parsed = cookieparser.parse(serverCookie)
return parsed[authCookieName] ? parsed[authCookieName] : null
if (parsed && parsed.authenticatedContent !== nullValue) {
return parsed[authCookieName] ? parsed[authCookieName] : null
} else {
return null
}
} else {
return null
}
Expand Down

0 comments on commit 78816bd

Please sign in to comment.