Skip to content

Instantly share code, notes, and snippets.

@arubis
Created November 15, 2016 20:39
Show Gist options
  • Save arubis/241106e6643c9241292860ddad1ff2e7 to your computer and use it in GitHub Desktop.
Save arubis/241106e6643c9241292860ddad1ff2e7 to your computer and use it in GitHub Desktop.
// depends on js-cookie.js: https://github.com/js-cookie/js-cookie
//
$(function(){
var user_logged_in = function() {
if(Cookies.get('auth_type')) {
console.log('user is logged in');
$(".menu-item > a[href|='/login']").replaceWith('<a title="Main Site" href="/">Main Site</a>');
$(".menu-item > a[href|='/signup']").hide();
} else {
console.log('user is _not_ logged in');
$(".menu-item > a[href|='/'").replaceWith('<a title="Log in" href="/login">Log in</a>');
$(".menu-item > a[href|='/signup']").show();
}
};
console.log(user_logged_in());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment