TransWikia.com

How to show Toaster after logout

Stack Overflow Asked on December 26, 2020

I have to show the toaster once I logout from the application. Here is what I am trying. Here I am calling toaster after my logout method.

_this.logout().then({
  success: function (result, request) {
    Ext.toast({
      html: 'Logged Out',
      width: 270,
      cls: 'smart-window alert-box',
      bodyStyle: 'background:#90EE90;',
    });
  },
  failure: function (result, request) {
    console.log('failure!');
  },
});

I have another approach where I am calling toaster before the logout but it is getting disapper after logout. How I can show toaster after logout whih is re directing on toaster page.

Here is my logout where I am redirecting.

logout: function (options) {
        let deferred = Ext.create("Deft.promise.Deferred");
        Ext.Ajax.request({
            url: '/logout',
            method: 'GET',
            success: function (result, request) {
                var url = '/myUrl/logout';
                var method = 'GET';
                Ext.Ajax.request({
                    url: url,
                    method: method,
                    success: function (result, request) {
                        let extraParam = "someconfig";
                        let external_logout = "/someurl";
                        
                        window.location.href = `${external_logout}${extraParam}`, 'width=1000 height=1000, scrollbars=yes, resizable=yes';
                        
                        deferred.resolve(logout);
                    },
                    failure: function (result, request) {
                        deferred.reject();
                    }
                });
            },
            failure: function (result, request) {
                Ext.MessageBox.alert('Failed', 'Request failed');
                deferred.reject();
            }
        });
        return deferred.promise;
    },

2 Answers

Maybe you could make use of localStorage. Set isLoggedOut=true just before redirecting.

And in the new Page check :

if(isLoggedOut===true)
    show toaster for 5/10 seconds. then set it to false;
else 
    continue as usual.

Answered by algo_user on December 26, 2020

then of promise object suppose to get only a callback.

_this.logout().then(() => {
  Ext.toast({
    html: 'Logged Out',
    width: 270,
    cls: 'smart-window alert-box',
    bodyStyle: 'background:#90EE90;',
  });
});

Answered by felixmosh on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP