luukhaijes / kinde-angular

Angular wrapper around the Kinde Typescript SDK
MIT License
8 stars 4 forks source link

Post login redirect functionality #12

Closed DaveOrDead closed 5 days ago

DaveOrDead commented 1 month ago

Hey @luukhaijes - Dave here from Kinde. Again, thanks for your awesome work on this :)

We've had a request come in to add post_login_redirect_url similar to the functionality available in the Kinde NextJS SDK.

This is the code they were hoping to use.

export class KindeAuthProviderGuard extends AuthProviderGuard {

    protected redirectIfUnauthenticated(state: RouterStateSnapshot): Observable<boolean> {
        const authService = inject(KindeAngularService);
        return authService.isAuthenticated$.pipe(
            take(1),
            tap(async isAuthenticated => {
                if (!isAuthenticated) {
                    await authService.login({
                        post_login_redirect_url: state.url
                    });
                }
            })
        );
    }
}

Unfortunately my Angular knowledge isn't there to implement this myself

luukhaijes commented 1 month ago

Hi Dave, thanks for opening this issue. As I can see I don't have a handler after login which does the redirection to the value given in post_login_redirect_url. I will create a fix for this.

luukhaijes commented 1 week ago

Fixed for a while by #13