angular7 - 会话过期时重定向到登录页面
问题描述
我将 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
};
}
解决方案
推荐阅读
- azure-cosmosdb - 在实时 Cosmos DB 数据库上禁用多主控
- node.js - 尝试安装新的模板 js 组件时出现此错误?
- python - Python 3,每当我尝试在同一个循环中使用 \r 和 time.sleep() 时,都没有输出
- php - 如何在 WooCommerce 中的单个产品页面上为显示的接近销售价格的折扣百分比添加 CSS 类
- scala - 不可变集合的 Builder#result 成本?
- r - 在随机森林 tidymodels r 中设置调整游侠的最大深度
- mysql - mysql 在一个查询中从消息表中为特定用户和每个朋友选择最后一条消息
- sql - SQL max last_Update 列
- python - Python - 全局变量没有改变
- swift - 如何在顶部的 UIView 上应用向下曲线