Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!cookies.hasOwnProperty('se')) {
let result = await fetch(`/api/session/generate`, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json'
}
}).then(res => res.json());
if (result['status'] === 'ok') {
nookies.set({}, 'se', result['session'], {
maxAge: 30 * 24 * 60 * 60,
path: '/',
});
nookies.set({}, 'to', result['token'], {
maxAge: 30 * 24 * 60 * 60,
path: '/',
});
}
}
this.setState({ loading: false })
}
Fingerprint2.get(options, (components) => {
var values = components.map(function (component) { return component.value });
var murmur = Fingerprint2.x64hash128(values.join(''), 31);
nookies.set({}, 'fp', murmur, {
maxAge: 30 * 24 * 60 * 60,
path: '/',
});
this.getSession(murmur);
});
} else {
const setAuthToken = (token: string, expiresIn: number, ctx?: NextPageContext) => {
const expires = expiresIn / 60 / 60 / 24;
if (isServer) {
nookies.set(ctx, AUTH_TOKEN_NAME, token, { maxAge: expires });
}
if (isClient) {
Cookies.set(AUTH_TOKEN_NAME, token, { expires });
}
};
let payload = {
fp: fingerprint
}
if (!cookies.hasOwnProperty('se')) {
let result = await fetch(`/api/session/generate`, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json'
}
}).then(res => res.json());
if (result['status'] === 'ok') {
nookies.set({}, 'se', result['session'], {
maxAge: 30 * 24 * 60 * 60,
path: '/',
});
nookies.set({}, 'to', result['token'], {
maxAge: 30 * 24 * 60 * 60,
path: '/',
});
}
}
this.setState({ loading: false })
}