Question

Logging out a user

Hey Community,
I'm trying to log out a user through JS.Is there way to do it ?
I'm aware that the db of the usersession can be updated, but it does bring a popup to the screen.Is there a workaround?
eg :
if ( some condition)
{  some custom function

}
else 

{  log the user out.

}
I did it check out this article, but unsure as to how to implement it 
https://community.creatio.com/questions/how-logout-user-after-checking-…

Like 1

Like

2 comments
Best reply

Hi,

 

Yes, you can call

 

Terrasoft.MainMenuUtilities.logout();

 

to logout the user. You can even test it in the developer console in the browser (just execute this line in the console).

 

As for how to use it - depends on your business task. You can call this logout method as a button click handler or using any other conditions suitable.

Hi,

 

Yes, you can call

 

Terrasoft.MainMenuUtilities.logout();

 

to logout the user. You can even test it in the developer console in the browser (just execute this line in the console).

 

As for how to use it - depends on your business task. You can call this logout method as a button click handler or using any other conditions suitable.

Oleg Drobina,

Thank you , this worked fine in the console however
Tried this out. However my code is not able to access the MainMenuUtilities.

So used the below instead 
  
                          sessionStorage.clear();
                         localStorage.clear();
                        window.location.href = window.location.origin;

Show all comments