Fixing JavaScript error when user is not logged in.