首页 > 解决方案 > 会话过期时重定向到登录页面

问题描述

我将 adal.js 用于我的 Angular 应用程序。当会话到期时,控制台中出现错误:

ERROR User login is required
Access to XMLHttpRequest at 'https://login.windows.net/de08c407-19b9-427d-9fe8-edf254300ca7/oauth2/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Fiboconfigservice.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback&client_id=828002a4-149f-478c-a318-933ad52b4c4f&scope=openid+profile+email&response_mode=form_post&nonce=58558408a18a4ee2a66e82121b92ea60_20190419101323&state=redir%3D%252Fapi%252FCalendar' (redirected from 'https://xxx.azurewebsites.net/api/ylendar') from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

但是,我不想解决一些错误,而是将用户重定向到登录页面。如何实现?adal.js - config中是否有任何规定?

或者任何人告诉我正确的方法来照顾这个?

这是我的配置:

export function getAdalConfig() {
  return {
    tenant: 'de08ccD7-19b9-427d-9fe8-edf254300ca7',
    clientId: '828002a4-149f-478c-a318-933ad52ererf',
    redirectUri: window.location.origin,
    endpoints: {
      "https://xxx.azurewebsites.net/api/":"828002a4-149f-478c-a318-233456"
    },
    navigateToLoginRequestUrl: false,
    cacheLocation: 'localStorage',
    expireOffsetSeconds: 600
  };
}

标签: angular7adal.js

解决方案


推荐阅读