askvortsov
I'm back to trying to detect if you are logged in or not in an extension. I'm trying to update the Direct Links extension so that if you are already logged in, the login modal will not show. Currently, the modal shows either way.
I've tried to simply wrap part of the existing code with an if statement. It breaks things.
How do I return LoginModal
only if you are logged out?
import RedirectToHomeAndOpenModalPage from './RedirectToHomeAndOpenModalPage';
import LogInModal from 'flarum/components/LogInModal';
import app from 'flarum/forum/app';
export default class LoginPage extends RedirectToHomeAndOpenModalPage {
createModal() {
const loggedin = app.session.user;
if (loggedin == null) {
return LogInModal;
}
}
}
Edit: The above code works. Just not with the Safari browser. Safari might be doing some sort of odd caching thing... or... I have no idea. All I know is the extension works in Chrome, but not Safari. Why, why, Safari, why? 🤯
Also, a note mainly for my future self, a better or at least more condensed way to do this is simply:
if (!app.session.user) {
return SignUpModal;
}