2017-05-09 44 views
0

當配置推送狀態與Aurelia和Visual Studio時,我得到一個奇怪的行爲,我選擇登錄後,我的整個應用程序重新加載,而不是路由器只是推到主頁。這也發生在我註銷時,我進入登錄屏幕並刷新整個應用程序。我正在使用Aurelia Auth。任何援助將不勝感激。Aurelia推送狀態應用程序重新加載登錄和註銷

回答

0

我覺得前段時間有同樣的問題,這是我轉回pushState = false的原因之一(但我的信息可能對您有所幫助)。

不管怎麼說,以下問題描述我面臨什麼:https://github.com/paulvanbladel/aurelia-auth/issues/55

的問題是,內部插件的href設置:

登錄 - https://github.com/paulvanbladel/aurelia-auth/blob/master/src/authentication.js#L95-L99

if (this.config.loginRedirect && !redirect) { 
    window.location.href = this.getLoginRedirect(); 
} else if (redirect && isString(redirect)) { 
    window.location.href = window.encodeURI(redirect); 
} 

註銷 - https://github.com/paulvanbladel/aurelia-auth/blob/master/src/authentication.js#L139-L143

if (this.config.logoutRedirect && !redirect) { 
    window.location.href = this.config.logoutRedirect; 
} else if (isString(redirect)) { 
    window.location.href = redirect; 
} 

您需要做的是避免這兩種情況,即將loginRedirectlogoutRedirect設置爲空字符串('')。然後,通過Aurelias路由器做導航你自己,因爲我在我的例子一樣從GH問題:

return this.auth.login(userInfo) 
    .then(response => { 
    console.log('You signed in successfully.'); 
    this.router.navigate('/contents'); 
    }) 

當然,做你的註銷方法在同一臺路由器導航。

+0

是的,這聽起來完全一樣的問題。看起來很奇怪,但我們必須破解它才能正常工作。我一直在考慮它的路由映射與Aurelia路由器的服務器端設置。它似乎並沒有像你的問題甚至在這裏回答https://github.com/paulvanbladel/aurelia-auth/issues/55 – jamesondev

+0

感謝您的回答。 – jamesondev