Coder Social home page Coder Social logo

Comments (8)

igorls avatar igorls commented on May 9, 2024

Same error happening here!

from nebular.

dannyrz avatar dannyrz commented on May 9, 2024

me too! how to fix it ? can anyone help me??

from nebular.

nnixaa avatar nnixaa commented on May 9, 2024

Hey Guys, could you please share a complete reproducible example?

from nebular.

dannyrz avatar dannyrz commented on May 9, 2024

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.

migueldelgado avatar migueldelgado commented on May 9, 2024

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.

nnixaa avatar nnixaa commented on May 9, 2024

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.

nsankaranarayanan avatar nsankaranarayanan commented on May 9, 2024

I had the same issue as @migueldelgado.
I resolved it by adding the below line.
import { getDeepFromObject } from '@nebular/auth/helpers';

from nebular.

issacvp avatar issacvp commented on May 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.