简体   繁体   English

如何从 ui5 应用程序注销并重定向到另一个 ui5 应用程序登录?

[英]How to Logout from a ui5 app and get redirected to another ui5 app login?

I have developed various UI5 apps and if i want to logout on one of them, all UI5 apps should be logout out.我开发了各种 UI5 应用程序,如果我想注销其中一个,所有 UI5 应用程序都应该注销。

For example.例如。 The first App is a menu.第一个应用程序是一个菜单。 So I login in the first Menu-App.所以我登录第一个菜单应用程序。 From this app there is a link to another app.从这个应用程序有一个链接到另一个应用程序。 Now i want to logout from this app and want to geht the redirect link to the menu-login.现在我想从这个应用程序中注销并想要将重定向链接指向菜单登录。

I have the following code for logout of the second app (not the menu-app):我有以下代码用于注销第二个应用程序(不是菜单应用程序):

    handleLogout: function (oEvent) {
      $.ajax({
        type: "GET",
        url: "/sap/.../logoff", 
      }).done(function (data) { 
        if (!document.execCommand("ClearAuthenticationCache")) {
          window.localStorage.clear()
          $.ajax({
            type: "GET",
            url: "/sap/.../logoff", 
            username: '', 
            password: '',
            statusCode: {
              401: function () {
              }
            },
            error: function () {
            }
          });
        }
      });
      var myVar = setInterval(function (oEvent) {
        window.location.replace("/sap/...->link to the menu<-");
      }, 100);
    },

The result of this code is, that i get redirected to the menu-app and not to its login.这段代码的结果是,我被重定向到菜单应用程序而不是它的登录名。 I guess because there am still logged in.我猜是因为仍然登录。

Is there a chance or some sort of code where i can logout of all existing ui5-apps?是否有机会或某种代码可以注销所有现有的 ui5 应用程序? Has it something to do with cache-settings?它与缓存设置有关吗?

Solution is related with your session mechanism.解决方案与您的 session 机制有关。 How to you manage user session?您如何管理用户 session? Are you using cookies or local storage?您使用的是 cookies 还是本地存储?
For example you need to invalidate cookies in logout process for cookie option.例如,您需要在 cookie 选项的注销过程中使 cookies 无效。

Check your ClearAuthenticationCache method, it is look like using local storage method.检查您的 ClearAuthenticationCache 方法,它看起来像使用本地存储方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM