Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getAtUserId = () => {
if (!onClient()) return null;
const cookieName = 'atuserid';
const cookie = Cookie.getJSON(cookieName);
let val = pathOr(null, ['val'], cookie);
const expires = 397; // expires in 13 months
if (!cookie || !val) {
val = uuid();
}
Cookie.set(cookieName, { val }, { expires, path: '/' });
return val;
};
export function loggedIn() {
return cookie.getJSON('token')
}
constructor(props) {
super(props);
const user = cookie.getJSON("user") || {loggedin:false};
this.state = {
user: user,
showSignInModal: false,
showBuyModal: false
};
this.handleSignedIn = this.handleSignedIn.bind(this);
this.handleSignedOut = this.handleSignedOut.bind(this);
this.showSignInModalWindow = this.showSignInModalWindow.bind(this);
this.toggleSignInModalWindow = this.toggleSignInModalWindow.bind(this);
this.showBuyModalWindow = this.showBuyModalWindow.bind(this);
this.toggleBuyModalWindow = this.toggleBuyModalWindow.bind(this);
}
cookie.prototype.get = function(str){
var data = {};
if (Cookies.get(this.config.key)) {
data = Cookies.getJSON(this.config.key);
}
if (str && typeof data === 'object' && typeof data !== null) {
return (typeof data[str] !== 'undefined') ? data[str] : null;
}
else {
return data;
}
};
syncWatchingCache: function() {
let watching = Cookies.getJSON('watching-repos');
if (!watching) {
watching = [];
}
watchingCache = watching;
}
getState: (key) => {
const user = Cookies.getJSON(key)
if ((user || {}).sessionToken) {
Vue.axios.defaults.headers.common['X-Parse-Session-Token'] = user.sessionToken
}
return { auth: { user } }
},
setState: (key, state) => Cookies.set(key, state.auth.user, { expires: 30 })
const flashes = storedFlash.map(flashName => {
const flash = Cookies.getJSON(flashName);
Cookies.remove(flashName);
return flash;
});
Cookies.remove("jsFlashNames");
public get(name: string): any {
return getJSON(name)
}
public get(name: string): any {
if (this.platformService.isBrowser) {
return getJSON(name)
} else {
try {
return JSON.parse(this.req.cookies[name])
} catch (err) {
return this.req ? this.req.cookies[name] : undefined
}
}
}