akveo / ngx-admin

Customizable admin dashboard template based on Angular 10+
https://akveo.github.io/ngx-admin/
MIT License
25.14k stars 7.95k forks source link

[Nebular/auth] nebular authorization flow broked in 2.0.2 release #1512

Closed visyone closed 6 years ago

visyone commented 6 years ago

Issue type

I'm submitting a ... (check one with "x")

Issue description

Current behavior: Implementation of authorization flow with nebular components doesn't works in 2.0.2 theme release

Expected behavior: The login page is shown after authorization flow has been implemented

Steps to reproduce:

The login page should appear, an error is shown instead in the browser console.

nebular_auth_err

The error occurs after the implementation of the AuthGuard service as described in the nebular documentation. Seems that the this.authService.isAuthenticated() method isn't resolved.

Other information:

Node: 8.9.4 npm: 5.6.0 OS: Windows 10 Browser: Chrome/Firefox/Edge

If I modify the package.json file downgrading the @nebular/theme and @nebular/auth modules from 2.0.0-rc.4 to 2.0.0-rc.3; launch npm upgrade and restart the theme; the login page is shown and the error disappear.

All works if I use 2.0.1 ngx-admin theme release without downgrading anything

nnixaa commented 6 years ago

Hi @visyone, can you give us more details on Implement nebular authorization flow as described in their documentation? As I'm just trying to replicate your stepts and it's working fine for me.

You are probably referring to this article https://akveo.github.io/nebular/#/docs/auth/protecting-application-routes, if so please add import 'rxjs/add/operator/do'; import inside of your route-guard, that should fix the issue.

visyone commented 6 years ago

Hi @nnixaa, I probably did not explain the behavior well. What I do is:

Opening the browser no login page appears, but I find an error in the browser console. From this point, after stopping the application, if I follow the steps below everything works (I see the login page):

Everything works without having to do anything if I take the first step starting with the source files (.zip) of version 2.0.1

I hope I have described everything necessary to reproduce the case. Thanks so much

nnixaa commented 6 years ago

Hi @visyone, thanks again for the detailed steps. May I ask you to add the following import import 'rxjs/add/operator/do'; on top of your guard and try again with rc4 nebular version?

visyone commented 6 years ago

Hi @nnixaa, I tryed to add the import and effectively the error disappear and all works.

This behavior is strange, I have replicated the case on two different machine and the same error occurs, all works normally for you instead.

Can be that the import that you mention is a missing import from nebular introduced in the 2.0.0-rc.4 release? If not I don't understand because this occurs.

nnixaa commented 6 years ago

Yes, previously the do operator was included in the release build, that's why it was working without the import. Starting from rc4 you need to import the rxjs operator you need manually. This is expected behavior so I'm closing the issue. We already updated the documentation to include a proper example. Thanks for your help!

visyone commented 6 years ago

Perfect, I update my code according to the aspected behavior.

Thanks to you!