Search code examples
angularnebular

Add custom field in Nebular Register Component


I have setup authentication for nebular using all of their components and used NbPasswordAuthStrategy as authentication strategy.

The register component currently has following inputs,

  1. Full Name
  2. Email
  3. Password
  4. Repeat Password

But my API requires me to have First Name and Last Name instead of Full Name. How do I go about configuring the framework so that it fits my custom needs?

I have researched on how to do this, but came up with no results. Neither the NbPasswordAuthStrategy setup has any way to customise the form nor there is an example provided for customising the form.

My Authentication config looks like this

{
  strategies: [
    NbPasswordAuthStrategy.setup({
      name: 'email',
      token: {
        class: NbAuthJWTToken,
        key: 'token'
      },
      baseEndpoint: 'api',
      login: {
        endpoint: '/auth/login',
        redirect: {
          success: '/pages/dashboard',
          failure: null,
        },
      },
      register: {endpoint: '/auth/register'},
    }),
  ],
  forms: {
    logout: {
      strategy: 'email'
    }
  },
} 

Solution

  • You can't customize auth components via auth module configuration instead you need to extend and customize Nebular auth components. Here is a guide.