Public
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Honored Contributor

How to force-logout a user?

Hello!

I just banned a spammer but I notice that they still show up as "logged in." Can I force a logout?

(side note: seems odd that banning a user doesn't automatically log them out)

Thanks!

6 Replies 6
Highlighted
Honored Contributor

I've wondered about this as well.  

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
Highlighted
Honored Contributor

Someone smarter from an engineering side could correct me, but I think the easiest way to 'kick them out' would be to just add a script to the page initialization that if the user status = banned, kick them to a banned page or some such thing. It would at least take care of letting them "in" until their session expires.

Also +1 you would think they would do this automatically.

Highlighted
Honored Contributor

@CarolineS,

As @StanGromer mentioned, we did the same thing with one of our community. We check the user status on page init, and if user is banned we redirect them to a banned page and logged them out from the community at the same time.

.......
Do you know we work with Kudos and Accepted Solution.
Highlighted
Honored Contributor

Thanks, @Parshant, @StanGromer, and @Gonzalles! Checking on page init seems straightforward enough. I’ll look into doing that.

Highlighted
Honored Contributor

@CarolineS, Also in addition to my answer, add this context object

${webUi.getUserLogoutPageUrl("/")}

in place of redirect_url of setRedirectUrl context-object

http.response.setRedirectUrl("redirect_url")

Once the condition is matched, it will take user to logout page.

P.S: Do not add redirect variable directly without condition into page init, it will take you into a continuous loop, and can result to server down error into your community.

 

.......
Do you know we work with Kudos and Accepted Solution.
Highlighted
Honored Contributor

@Parshant - thank you so much! Super useful!