Comments (8)
Same error happening here!
from nebular.
me too! how to fix it ? can anyone help me??
from nebular.
Hey Guys, could you please share a complete reproducible example?
from nebular.
App.module.ts
//auth-vz1 is renamed from folder auth for debug
/**
- @license
- Copyright Akveo. All Rights Reserved.
- Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { APP_BASE_HREF } from '@angular/common';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { CoreModule } from './@core/core.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { ThemeModule } from './@theme/theme.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NbEmailPassAuthProvider, NbAuthModule } from '@nebular/auth-vz1';
import { NB_AUTH_TOKEN_WRAPPER_TOKEN, NB_AUTH_OPTIONS_TOKEN, NbAuthJWTToken } from '@nebular/auth-vz1';
import { getDeepFromObject } from '@nebular/auth-vz1/helpers';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpModule,
AppRoutingModule,
NgbModule.forRoot(),
ThemeModule.forRoot(),
CoreModule.forRoot(),
NbAuthModule.forRoot({
providers: {
email: {
service: NbEmailPassAuthProvider,
config: {
baseEndpoint: 'http://localhost:53094',
login: {
alwaysFail: false,
rememberMe: true,
endpoint: '/api/Auth/Login',
method: 'post',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Login/Email combination is not correct, please try again.'],
defaultMessages: ['You have been successfully logged in.'],
},
register: {
alwaysFail: false,
rememberMe: true,
endpoint: '/api/auth/register',
method: 'post',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['You have been successfully registered.'],
},
logout: {
alwaysFail: false,
endpoint: '/api/auth/logout',
method: 'delete',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['You have been successfully logged out.'],
},
requestPass: {
endpoint: '/api/auth/request-pass',
method: 'post',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['Reset password instructions have been sent to your email.'],
},
resetPass: {
endpoint: '/api/auth/reset-pass',
method: 'put',
redirect: {
success: '/',
failure: null,
},
resetPasswordTokenKey: 'reset_password_token',
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['Your password has been successfully changed.'],
},
token: {
**_//key: 'data.token',
//getter: function (module, res) { return getDeepFromObject(res.body, _this.getConfigValue('token.key')); },_** HERE SHOWS THE ERROR
key: 'Value', // 改为后台返回的值
getter: (module: string, res: HttpResponse<Object>) => {
// debug by zhurizhao //console.log( res.body );
return getDeepFromObject(res.body, 'Value');
},
},
errors: {
key: 'data.errors',
getter: (module: string, res: HttpErrorResponse) => getDeepFromObject(res.error,
this.getConfigValue('errors.key'),
this.getConfigValue(`${module}.defaultErrors`)),
},
messages: {
key: 'data.messages',
getter: (module: string, res: HttpResponse<Object>) => {
// debug by zhurizhao
// console.log(this);
// 可能时官方的一个BUG先注释掉
// getDeepFromObject(res.body,
// this.getConfigValue('messages.key'),
// this.getConfigValue(`${module}.defaultMessages`));
let defaultMessages = '';
if ( module === 'login') {
defaultMessages = '登陆成功,正在跳转..';
}
return getDeepFromObject(res.body, 'data.messages', defaultMessages);
},
},
},
},
},
}),
],
bootstrap: [AppComponent],
providers: [
NbAuthJWTToken,
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: NB_AUTH_TOKEN_WRAPPER_TOKEN, useClass: NbAuthJWTToken },
],
})
export class AppModule {
}
from nebular.
Same issue with me, I get cannot find name 'getDeepFromObject' and also getConfigValue doesnt exist.
const NB_CORE_PROVIDERS = [
...DataModule.forRoot().providers,
...NbAuthModule.forRoot({
providers: {
email: {
service: NbEmailPassAuthProvider,
config: {
delay: 3000,
baseEndpoint: 'http://laravel.dev',
login: {
endpoint: '/api/login',
method: 'post',
rememberMe: false,
redirect: {
success: '/',
failure: null
},
defaultErrors: ['Email/Password combinacion incorrecta, porfavor intenta denuevo'],
defaultMessages: ['Te haz conectado correctamente'],
},
logout: {
alwaysFail: false,
endpoint: '/api/logout',
method: 'delete',
redirect: {
success: '/auth/login',
failure: null,
},
defaultErrors: ['Algo salio mal porfavor intenta denuevo'],
defaultMessages: ['Has salidos correctamente de la aplicacion'],
},
requestPass: {
endpoint: '/api/auth/request-pass'
},
resetPass: {
endpoint: '/api/auth/reset-pass'
},
token: {
key: 'data.token',
getter: (module: string, res: HttpResponse<Object>) => getDeepFromObject(res.body,
this.getConfigValue('token.key')),
},
},
},
},
}).providers,
AnalyticsService,
];
from nebular.
Okay, there is a problem with using getConfigValue
outside of the AuthModule, as it will be executed in the current context, and of course, you don't have it in you module
. I believe in this case the simplest way would be to not specify the methods you don't need to overwrite, like getter: (module: string ...
.
from nebular.
I had the same issue as @migueldelgado.
I resolved it by adding the below line.
import { getDeepFromObject } from '@nebular/auth/helpers';
from nebular.
Hi All,
I also had the same issue and resolved by below steps.
First make sure that the back end service returns the success response as below
{
data : {
token :
}
}
Then change the configuration in app.module.ts
Effectively I replaced ' this.getConfigValue('token.key')' to 'data.token' (Which is actually the method supposed to do, I think)
From
-----
token: {
key: 'data.token',
getter: (module: string, res: HttpResponse) => getDeepFromObject(res.body,
this.getConfigValue('token.key')),
},
To
----
token: {
key: 'data.token',
getter: (module: string, res: HttpResponse) => getDeepFromObject(res.body,
'data.token'),
},
Take care of all the getConfigValue() in app.module.ts
Good luck all.
from nebular.
Related Issues (20)
- Install Nebular theme error -> Could not read Angular module file: /src/[object Object].ts HOT 8
- [Calendar] [DatePicker] components aren't translated when switching languages HOT 1
- nb-tabset not workign with ng-content
- The Nebular Dropdown (nbSelect) remains open and does not collapse when scrolling the page. HOT 1
- caught error defaultview
- error handling when serve the project(ng serve) I'm using angular 12th version
- logout
- logout
- pipe table
- Theme is not a map.
- Could not read Angular module file: /src/null.ts (Standalone) or /src/[object Object].ts (ng modules) HOT 6
- Docs: latest version 9.0.0 but appear to have version 13 installed HOT 2
- NbTreeGrid Error NullInjectorError: No provider for InjectionToken CDK_TABLE! HOT 10
- RangePicker only Month and Year
- Request for Multiline Input Support in <nb-chat-from> Component
- angular/[email protected]: [ERROR] TS2610 in NbTable HOT 8
- Same issue with Angular 17
- When I open an NbDialog first and then open an NbWindow, the window will be displayed behind the dialog. How can I resolve this issue?
- When I tried to open a dialog, the following exception occurred.
- customized login style HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nebular.