akveo / akveo/ngx-admin

NullInjectorError: No provider for NbOverlayService

Aberta
#5,627 6 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
25.7k
Forks
7.9k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

### Issue type

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

* [ x] bug report
* [ ] feature request
* [ ] question about the decisions made in the repository

### Issue description

**Current behavior:**
`ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[AuthGuard -> NbAuthService -> NbTokenService -> NbTokenStorage -> NbAuthTokenParceler -> InjectionToken Nebular Auth Tokens -> InjectionToken Nebular Auth Strategies -> FirebaseAuthStrategy -> NbToastrService -> NbToastrContainerRegistry -> NbOverlayService -> NbOverlayService -> NbOverlayService]:
NullInjectorError: No provider for NbOverlayService!
NullInjectorError: R3InjectorError(AppModule)[AuthGuard -> NbAuthService -> NbTokenService -> NbTokenStorage -> NbAuthTokenParceler -> InjectionToken Nebular Auth Tokens -> InjectionToken Nebular Auth Strategies -> FirebaseAuthStrategy -> NbToastrService -> NbToastrContainerRegistry -> NbOverlayService -> NbOverlayService -> NbOverlayService]: `

**Expected behavior:**
Auth to work properly as it did with angular 8 and @nebular 4

**Steps to reproduce:**
- Install ngx-admin
- Upgrade to Angular 9 and the nebular components to 5.0.0
- Add an AuthModule to override the NbAuthModule.
- Add a new auth.service into the Auth module
- Add a new strategy to connect to firebaseAuth instead of REST API.
- Remove the user service and replace with service that collects users from firebase.

**Related code:**

> app.module.ts
```
...
@NgModule({
declarations: [
AppComponent
] ,
imports: [
CommonModule,
BrowserModule ,
BrowserAnimationsModule ,
HttpClientModule ,
AppRoutingModule ,
AngularFireModule.initializeApp(fireConfig) ,
AngularFirestoreModule ,
AngularFireAuthModule ,
AngularFireAuthModule ,
ThemeModule,
NbLayoutModule ,
NbEvaIconsModule ,
NbSidebarModule.forRoot() ,
NbMenuModule.forRoot() ,
NbDatepickerModule.forRoot() ,
NbDialogModule.forRoot() ,
NbWindowModule.forRoot() ,
NbToastrModule.forRoot() ,
NbChatModule.forRoot({
messageGoogleMapKey: 'AIzaSyA_wNuCzia92MAmdLRzmqitRGvCF7wCZPY' ,
}) ,
CoreModule.forRoot() ,
] ,
providers: [] ,
bootstrap: [AppComponent]
})
export class AppModule {
}
```
> auth.module.ts
```

@NgModule({
declarations: [LoginComponent , RegisterComponent , ForgotPasswordComponent , ResetPasswordComponent] ,
imports: [
CommonModule ,
AuthRoutingModule ,
AngularFireAuthModule ,
AngularFirestoreModule ,
FormsModule,
RouterModule,
NbAlertModule,
NbInputModule,
NbButtonModule,
NbCheckboxModule,
NbIconModule,
ThemeModule
] ,
providers: [
AuthService ,
AuthGuard ,
FirebaseAuthStrategy ,
{provide: HTTP_INTERCEPTORS , useClass: NbAuthJWTInterceptor , multi: true} ,
{provide: HTTP_INTERCEPTORS , useClass: HttpErrorInterceptor , multi: true , deps: [NbToastrService , Router]} ,
] ,
exports: [
LoginComponent ,
RegisterComponent ,
ForgotPasswordComponent ,
ResetPasswordComponent]
})
export class AuthModule {
}
```

> core.module.ts
```
import {FirebaseAuthStrategy} from 'projects/admin-landing/src/app/auth/firebase-strategy';

const socialLinks = [
{
name: 'facebook' ,
icon: 'socicon-facebook' ,
} ,
{
name: 'google' ,
icon: 'socicon-google' ,
} ,
];

const DATA_SERVICES = [
{provide: UserData , useClass: UserService} ,
];

export class NbSimpleRoleProvider extends NbRoleProvider {
getRole() {
// here you could provide any role based on any auth flow
return observableOf('guest');
}
}

export const NB_CORE_PROVIDERS = [
...DATA_SERVICES ,
...NbAuthModule.forRoot({
strategies: [
FirebaseAuthStrategy.setup({
name: 'firebase' ,
token: {
class: NbAuthJWTToken ,
} ,
checkEmail: true ,
}) ,
] ,
forms: {
login: {
socialLinks: socialLinks ,
} ,
register: {
socialLinks: socialLinks ,
} ,
validation: {
password: {
required: true ,
minLength: 8 ,
maxLength: 42 ,
} ,
email: {
required: true ,
} ,
fullName: {
required: true ,
minLength: 4 ,
maxLenght: 42 ,
} ,
} ,
} ,
}).providers ,

NbSecurityModule.forRoot({
accessControl: {
guest: {
view: '*' ,
} ,
user: {
parent: 'guest' ,
create: '*' ,
edit: '*' ,
remove: '*' ,
} ,
} ,
}).providers ,

{
provide: NbRoleProvider , useClass: NbSimpleRoleProvider ,
} ,
AnalyticsService ,
FirebaseAuthStrategy ,
FirestoreService ,
];

@NgModule({
imports: [
CommonModule ,
AuthModule
] ,
exports: [
NbAuthModule ,
] ,
declarations: [] ,
})
export class CoreModule {

static forRoot(): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
...NB_CORE_PROVIDERS,
],
};
}
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, 'CoreModule');
}
}
```

### Other information:

**npm, node, OS, Browser**
```
Angular CLI: 9.1.0
Node: 12.16.1
OS: darwin x64

Angular:
...
Ivy Workspace:

Package Version
------------------------------------------------------
@angular-devkit/architect 0.901.0
@angular-devkit/core 9.1.0
@angular-devkit/schematics 9.1.0
@schematics/angular 9.1.0
@schematics/update 0.901.0
rxjs 6.5.4
```

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.