Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('Create an instance with existing token on cookies', t => {
browserEnv(['window', 'document']);
const Cookies = require('js-cookie');
const globalAny: any = global;
Cookies.set('jwt', 'XXX');
// const CookieGet = sinon.spy(Cookies)
const strapi = new Strapi('http://strapi-host', {
localStorage: false
});
t.is(strapi.axios.defaults.headers.common.Authorization, 'Bearer XXX');
// TODO: Mock Cookies
// t.true(CookieGet.calledWith('jwt'));
delete strapi.axios.defaults.headers.common.Authorization;
delete globalAny.window;
});
@action.bound onAccept() {
// Set a cookie for 3 years
Cookies.set(COOKIE_NAME, VERSION, { expires: 365 * 3 })
this.accepted = true
}
login: function (data) {
console.log(data);
Cookie.set('X-App-Name', data.username);
Cookie.set('X-App-Email', data.email);
Cookie.set('X-App-UID', data.uid);
Cookie.set('X-App-Token', data.token);
Cookie.set('X-App-Role', data.role);
Cookie.set('X-App-Logo', data.logo);
Cookie.remove('X-App-Github');
const info = this.info();
Event.emit('login', info);
},
const setAuthCookie = (accessToken: string, tokenExpiresIn: number) => {
if (!process.browser) {
return;
}
const cookieExpiry = new Date(new Date().getTime() + tokenExpiresIn * 1000);
Cookie.set(ACCESS_TOKEN_COOKIE_NAME, accessToken, { expires: cookieExpiry });
};
export const setToken = token => {
if (!process.browser) {
return;
}
Cookies.set("username", token.user.username);
Cookies.set("jwt", token.jwt);
if (Cookies.get("username")) {
Router.push("/");
}
};
export const setToken = (idToken, accessToken) => {
if (!process.browser) {
return
}
Cookie.set('user', jwtDecode(idToken))
Cookie.set('idToken', idToken)
Cookie.set('accessToken', accessToken)
}
document.addEventListener('turbolinks:load', event => {
moment.locale(gon.user.locale);
Cookies.set('ann_time_zone', moment.tz.guess(), {
domain: '.annict.com',
secure: true
});
Vue.config.debug = true;
Vue.use(VueLazyload);
Vue.component('c-activities', activities);
Vue.component('c-adsense', adsense);
Vue.component('c-amazon-item-attacher', amazonItemAttacher);
Vue.component('c-analytics', analytics(event));
Vue.component('c-body', body);
Vue.component('c-channel-receive-button', channelReceiveButton);
Vue.component('c-channel-selector', channelSelector);
Vue.component('c-comment-guard', commentGuard);
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
if (state.sidebar.opened) {
Cookies.set('sidebarStatus', 1)
} else {
Cookies.set('sidebarStatus', 0)
}
},
CLOSE_SIDEBAR: (state, withoutAnimation) => {