Angular-auth-oidc-client: Using with NRGX/Redux

Created on 1 Sep 2017  路  9Comments  路  Source: damienbod/angular-auth-oidc-client

Good day:

I am trying to use your library with the NRGX library which I am using for the very first time. My observables skills are lacking currently as well.

I was wondering if you could point in the right direction to handle authorizedCallback method as an observable in my side effect class. I would like to handle like below example.

@Effect()
    attemptPostAuthenticationLogic$ = this.actions$
        .ofType(fromAuth.ATTEMPT_POST_AUTHENTICATION_LOGIC)
        .switchMap(() => {

            if (window.location.hash) {
                this.oidcervice.authorizedCallback(window.location.hash)
                .map(isAuthorize => new fromAuth.UserAuthenticated({ user: null, isSignedIn: true, isSignOut: false }));                    

            } else {
                return of(new fromAuth.InitializeAutneticationServiceComplete());
            }
        });

Do you think there is better way I could handle this. thanks

investigate question

All 9 comments

@shaannder just learning NRGX myself now :) I'm looking into this now. I'll get back as soon as I know more. Maybe @FabianGosebrink @philipooo coud helpher, they have been trying out NRGX.

Greetings Damien

Maybe when sending a auth request you can spread the state with a property "pending" and when the call comes back you can attach a new action like "AUTHENTICATION_SUCCESS" to the store.

I am not yet familiar with the angular-auth-oidc-client module so I may cant help you out on this. But I want to mention that there is a missing return statement at line 7 of your example code. return this.oidcervice.authorizedCallback...

Thanks for the feedback guys, I will keep plugging away and keep you up to date as well with my progress.

One quick observation though, currently the authorizedCallback is not observable, is it possible to make this observable or expose a similar implementation that is observable. Return a observable and also leave the redirection to the home or unauthorize route to the subscriber. Let me know what you think.

thanks.

Sorry guys but I am shaannder, Never realized I was logged into a test account I a just setup.

Hi @chispaK

You can set trigger_authorization_result_event to false and use the @Output() onAuthorizationResult: EventEmitter instead.

https://github.com/damienbod/angular-auth-oidc-client/blob/master/API_DOCUMENTATION.md#trigger_authorization_result_event

Greetings Damien

Thanks Damien...

Do i see a library like ngrx/router-store comming up for auth ??

This is possible, but need to make shore that the used store is a global store and not a module store, if you want to reuse. and also if you subscribe to the store, then also unsubsubscribe in the ngDestroy

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Expelz picture Expelz  路  4Comments

haidelber picture haidelber  路  3Comments

vicver82 picture vicver82  路  4Comments

profet23 picture profet23  路  3Comments

brentos99 picture brentos99  路  4Comments