2016-07-29 37 views
0

我們正在開發處理OpenID Connect隱式流程的組件。在組件中處理具有特定功能的請求

step 5 of the flow中,「授權服務器使用ID令牌將最終用戶發送回客戶端,並在需要時將訪問令牌發回給客戶端。我們希望我們的組件能夠處理該請求,這將是~/openid-login

我們如何配置Aurelia使其路由到我們的組件中的函數?

export class OpenId { 

    // how do we route ~/openid-login to this? 
    public handleRequest() { 

    } 

} 

注:Here is the work in progress.

回答

2

您routeConfig內使用navStrategy將允許你做任何你導航到一個頁面之前喜歡。請看下圖:

import { autoinject } from 'aurelia-framework'; 
import { RouterConfiguration, Router, NavigationInstruction } from 'aurelia-router'; 

@autoinject 
export class App { 

    router: Router; 

    configureRouter(config: RouterConfiguration, router: Router) { 

     let openIdNavStrat = (instruction: NavigationInstruction) => { 

      console.log('Do whatever we would like to do.'); 

      // then redirect to where ever you would like. 
      instruction.config.moduleId = 'login'; 
     } 

     config.map([ 
      { route: ['', 'login'], moduleId: 'login' }, 
      { route: 'openid-login', navigationStrategy: openIdNavStrat }, 
     ]); 

     this.router = router; 
    } 
} 

有文件上的導航策略在這裏:http://aurelia.io/hub.html#/doc/article/aurelia/router/latest/router-configuration/3

+0

會,這也要求我們有一個其中有一個路由器視圖的app.html看法? –