Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rehydrate(state) {
this.options = state.options;
this.lastVisit = state.lastVisit;
this.isFirstTime = state.isFirstTime;
this.version = state.version;
// TODO: Don't call this everytime.
if (reactCookie.load('isFirstTime') !== state.isFirstTime) {
reactCookie.save('isFirstTime', state.isFirstTime);
}
if (reactCookie.load('version') !== state.version) {
reactCookie.save('version', state.version.replace(/\"/g, '').replace(/\\/g, ''));
}
}
dismissBanner(e) {
if (e && e.preventDefault) e.preventDefault();
this.setState({showBanner: false});
// set cookie to keep the banner dismissed persistently
Cookie.save('showBanner', 'no');
}
export function setOption(payload) {
const options = cookie.load('options') || {}; // protect against first timers.
Object.keys(payload).forEach((option) => {
options[option] = payload[option];
});
cookie.save('options', JSON.stringify(options));
return {
type: SET_OPTION,
payload
};
}
.subscribe((res) => {
cookie.save('WRANGLER_WORKSPACE', workspaceId);
WranglerStore.dispatch({
type: WranglerActions.setWorkspace,
payload: {
workspaceId,
data: res.value,
headers: res.header
}
});
}, (err) => {
console.log('err', err);
handleVersionChange(event) {
const { dispatch, contentIndex, contentData } = this.props
dispatch(ActionCreators.setVersion({
id: parseInt(event.target.value),
index: contentIndex
}))
cookie.save('last_bible_version', parseInt(event.target.value), { maxAge: moment().add(1, 'y').toDate(), path: '/' })
cookie.remove('last_bible_book')
dispatch(ActionCreators.setField({ index: contentIndex, field: 'human', value: ' ' }))
dispatch(ActionCreators.setField({ index: contentIndex, field: 'chapter', value: '' }))
dispatch(ActionCreators.setField({ index: contentIndex, field: 'usfm', value: [''] }))
}
install() {
const { daysReminder } = this.props;
if (!daysReminder) return null;
let expireDate = new Date();
expireDate = new Date(
expireDate.setDate(expireDate.getDate() + daysReminder)
);
this.hide();
cookie.save('smartbanner-installed', 'true', {
path: '/',
expires: expireDate,
});
return null;
}
.then((res) => {
cookie.save('CDAP_Auth_Token', res.access_token, { path: '/' });
cookie.save('CDAP_Auth_User', this.state.username);
var queryObj = util.getQueryParams(location.search);
queryObj.redirectUrl = queryObj.redirectUrl || '/';
window.location.href = queryObj.redirectUrl;
});
}
AppActions.getSingleDeployment(id, function(data) {
if (data.status === "finished") {
self.setState({onboardDialog: true});
cookie.save(self.state.user.id+'-onboarded', true);
cookie.remove(self.state.user.id+'-deploymentID');
}
});
},
onLogin(sess) {
cookie.save('userId', sess.UserId, { path: '/' });
cookie.save('userSessionKey', sess.SessionKey, { path: '/' });
this.setState({ userId: sess.UserId,
userSessionKey: sess.SessionKey });
}
export function setToken(token) {
cookie.save('x-access-token', token, {
expires: moment().add(1, 'h').toDate(),
});
}