Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toggleFollow() {
if (!this.data.get('isAuthenticated')) {
router.locator.redirect('/login');
return;
}
let author = this.data.get('article.author');
this.actions[author.following ? 'unfollow' : 'follow'](author.username)
.then(data => {
this.actions.setAuthor(data.profile);
console.log(data.profile)
});
},
logout() {
this.actions.logout();
router.locator.redirect('/');
}
}))
.then(data => {
if (data.errors) {
this.data.set('inProgress', null);
return;
}
router.locator.redirect(`/article/${data.article.slug}`);
});
},
handleRedirect(item) {
if (item.key) {
router.locator.redirect(item.key);
}
}
}
this.actions.register({username, email, password}).then(data => {
if (data.user) {
router.locator.redirect('/');
}
});
}
this.actions.login({email, password}).then(data => {
if (data.user) {
router.locator.redirect('/');
}
});
}
export function routeTo(url, params = {}) {
let paramsArr = Object.keys(params).map((key) => `${key}=${params[key]}`);
let urlParams = (url.indexOf('?') > -1 ? '&' : '?') + paramsArr.join('&');
router.locator.redirect(urlParams.length > 1 ? `${url}${urlParams}` : url);
}