Angular 使用MsalService';s loginRedirect():ngrx效果中确定登录成功的void方法?

Angular 使用MsalService';s loginRedirect():ngrx效果中确定登录成功的void方法?,angular,ngrx,msal,ngrx-effects,Angular,Ngrx,Msal,Ngrx Effects,我正在使用Azure广告登录我的angular应用程序。使用MSAL,我可以使用MsalService的loginPopup()方法来完成这项工作。我还使用ngrx来管理我的状态。相关代码摘录如下所示 “登录”页面上的“登录”按钮调用 login(): void { this._store.dispatch(new Login()); } 是什么触发了这一行动 export class Login implements Action { readonly type = Auth

我正在使用Azure广告登录我的angular应用程序。使用MSAL,我可以使用MsalService的
loginPopup()
方法来完成这项工作。我还使用ngrx来管理我的状态。相关代码摘录如下所示

“登录”页面上的“登录”按钮调用

login(): void {
    this._store.dispatch(new Login());
}
是什么触发了这一行动

export class Login implements Action {
    readonly type = AuthActionTypes.LOGIN;
}
它本身被一个效果捕获,即成功接收id_令牌时检查其签名的有效性(成功后,签名将发送LoginSucess操作)。否则,通过调度LoginFail操作,将认为登录失败

@Effect()
doLogin$: Observable<Action> = this._actions$.pipe(
    ofType<Login>(AuthActionTypes.LOGIN),
    switchMap(() => {
        return observableFrom(this._msal.loginPopup()).pipe(
            map(idToken => new CheckTokenValidity(idToken)),
            catchError(error => of(new LoginFail(error)))
        );
    })
);
@Effect()
多洛金$:可观察=此。_actions$.pipe(
ofType(AuthActionTypes.LOGIN),
开关映射(()=>{
返回observeFrom(this.msal.loginPopup()).pipe(
映射(idToken=>new CheckTokenValidity(idToken)),
catchError(错误=>of(新登录邮件(错误)))
);
})
);
但是,这可以很好地工作,而不是使用
MsalService.loginPopup():Promise
我现在想使用
MsalService.loginDirect():void
。但作为一个问题,我希望我的ngrx效果链会断开,因为这样就没有承诺了,只有虚空返回

我该如何着手解决这个问题


干杯

这是一个老问题,但我会给出答案,因为在搜索NGRX和Msal/Adal时它仍然会弹出

更新你的效果,使其不发送动作,否则会断链

@Effect({dispatch: false)
doLogin$: Observable<Action> = this._actions$.pipe(
    ofType<Login>(AuthActionTypes.LOGIN),
    tap(() => {
        // void function
    })
);
@Effect({dispatch:false)
多洛金$:可观察=此。_actions$.pipe(
ofType(AuthActionTypes.LOGIN),
点击(()=>{
//空洞函数
})
);

这是一个老问题,但我会给出答案,因为在搜索NGRX和Msal/Adal时,它仍然会弹出

更新你的效果,使其不发送动作,否则会断链

@Effect({dispatch: false)
doLogin$: Observable<Action> = this._actions$.pipe(
    ofType<Login>(AuthActionTypes.LOGIN),
    tap(() => {
        // void function
    })
);
@Effect({dispatch:false)
多洛金$:可观察=此。_actions$.pipe(
ofType(AuthActionTypes.LOGIN),
点击(()=>{
//空洞函数
})
);