Can I add any other Log Out button somewhere?


(Michael Downey) #1

Continuing the discussion from Logging out dismisses notification count:

Once again we had a complaint that someone can’t log out without dismissing notification count. This really stinks.

This is also a problem when impersonating a user, because you can’t stop the impersonation session without dismissing their notifications without their permission.

Question: How can we add a log out link in a place that won’t be so disruptive? :frowning:


(Dean Taylor) #2

As a workaround I usually:

  • open a Chrome Incognito window
  • login as myself
  • impersonate
  • just close Incognito window to logout.

This specifically avoids executing the “logout” which would log users out of all sessions on all devices.


EDIT:

Alternatively if the Discourse instance uses SSO against another authentication provider then you can just visit '/session/sso` and that will log you back in as yourself.


(Sam Saffron) #3

Log out is usually a bad fit for finishing impersonation. It will log the user out everywhere.

Instead either use incognito as @DeanMarkTaylor said or delete cookies


(Michael Downey) #4

Thanks to the disabled log out strict site setting we don’t participate in such default nonsense. :slight_smile:

That said, anyone with ideas to my original question about how to add a Log Out link somewhere else in the UI other than the notification list?


(Sam Saffron) #5

You could probably use a site customization to add to hamburger, but seems like a poor fit conceptually


(Michael Downey) #6

Really? Isn’t that where it used to be? :wink:

EDIT: I went back and looked and yes, it was always under the user icon, but the notifications had their own menu and weren’t there to get in the way of account actions back in the day.


(Jeff Atwood) #7

I thought we had discussed a keyboard shortcut for this?


(Dean Taylor) #8

It is a poor fit - but here is how it could be done - but I don’t like it - way to accessible for the average user to shoot themselves in the foot:

Added to </head> customisation:

<script type='text/x-handlebars' data-template-name='/connectors/site-map-links-last/log-out'>
{{#if currentUser}}
<li>{{d-link action="logout" class="logout" icon="sign-out" label="user.log_out"}}</li>
{{/if}}
</script>
<script type="text/discourse-plugin" version="0.1">
var HamburgerMenuComponent = require('discourse/components/hamburger-menu').default;

HamburgerMenuComponent.reopen({
    actions: {
        logout: function() {
            this.container.lookup('controller:application').send('logout')
        }
    }
});
</script>

EDIT: Actually this doesn’t quite work clicking the logout, just reloads the page for me
EDIT: Got it working with additional script block


(Dean Taylor) #9

It’s shift+z shift+z


(Michael Downey) #10

This works, but why so cryptic and not just a single Shift+Z (and be placed on the keyboard shortcut help menu?)

Some of the comments here make it sound like logging out is some kind of horrible action… :confused:


(cpradio) #11

It is on the keyboard shortcut menu :wink:


(Jay Pfaffman) #12

A UX answer: What else would you do with Z? If it were a single Z then it would be too easy to do it by mistake.

The real answer: Because vi.


(Michael Downey) #13

Meh, I use :wq. (Old-school.)


(Jay Pfaffman) #14

Me too, in spite of the two extra keystrokes.

Most Discourse users, though, are more familiar with vi than ed. I suggested ^X^C, but it was a non-starter.


(Dean Taylor) #15

Also another workaround…

If the Discourse instance uses SSO against another authentication provider…

Then you can just visit /session/sso and that will log you back in as yourself.