public start()

in public/plugin.ts [144:176]


  public start(core: CoreStart): SecurityPluginStart {
    const config = this.initializerContext.config.get<ClientConfigType>();

    setupTopNavButton(core, config);

    if (config.ui.autologout) {
      // logout the user when getting 401 unauthorized, e.g. when session timed out.
      core.http.intercept({
        responseError: (httpErrorResponse, controller) => {
          if (
            httpErrorResponse.response?.status === 401 &&
            !(
              window.location.pathname.toLowerCase().includes(LOGIN_PAGE_URI) ||
              window.location.pathname.toLowerCase().includes(CUSTOM_ERROR_PAGE_URI)
            )
          ) {
            if (config.auth.logout_url) {
              window.location.href = config.auth.logout_url;
            } else {
              // when session timed out, user credentials in cookie are wiped out
              // refres the page will direct the user to go through login process
              window.location.reload();
            }
          }
        },
      });
    }

    if (config.multitenancy.enabled) {
      addTenantToShareURL(core);
    }
    return {};
  }