Switch to desktop version  
Script to force logoff/logout in viewON - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: Custom Web Pages/viewON/Talk2M Visualization (https://techforum.ewon.biz/forum-55.html)
+--- Thread: Script to force logoff/logout in viewON (/thread-1896.html)



Script to force logoff/logout in viewON - simon - 17-12-2021

Hi Guys,

If you just want to create a button to be able to change the user logged in viewON, you can use this viewON Script/Javascript.

This will force the logoff of the current user and prompt for new credentials

Code:
        var d = '111111111111',
       hostParts = window.location.href.split('/');
       url = hostParts[0] + '//'+d+':'+d+'@';

       if (window.location.href.indexOf("m2web.talk2m.com") > -1)     
         url += hostParts[2]  + '/' + hostParts[3]  + '/' +  hostParts[4]  +'/Ast/MainAst.shtm?nocache='+(new Date().getTime());
       else
         url += hostParts[2]  + '/Ast/MainAst.shtm?nocache='+(new Date().getTime());

       $.ajax(
       {
            type: "get",
            url: url,
            timeout: 15000,
            error: function(jqXHR, status)
            {
                 window.location.href = '../../usr/login.html';
            },
            // should not occur
            success: function(jqXHR, status)
            {
                 window.location.href = '../../usr/login.html';
            }
         });
         



RE: Script to force logoff/logout in viewON - ziozetti - 17-12-2021

This is great Simon!
This script is very useful when you want to test user's rights.

I just changed both:

Code:
              window.location.href = '../../usr/login.html';

with:

Code:
              window.location.href = '../../usr/viewon/Home.shtm';

Where Home is name of the view where button is placed and it works like a charm.


RE: Script to force logoff/logout in viewON - simon - 17-12-2021

Oh yes ! Forgot that :-)
Good point !
Thx for your loyalty