This package has been deprecated

Author message:

no longer maintained

tbdevkit-ngauth
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Tbdevkit-ngauth v 0.0.3

How to use

Install package

npm install tbdevkit-ngauth --save-dev

Import module in app module, with custom configuration:

const APP_AUTH_CONFIG: AuthConfig = {
  loginApiEndpoint: '/api/login',
  userApiEndpoint: '/api/user',
  rolesApiEndpoint: '/api/userroles',
  permissionsApiEndpoint: '/api/userpermissions',
};

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    DashboardComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    RouterModule.forRoot(routes),
    FormsModule,
    ReactiveFormsModule,
    TbdevkitAuthModule.forRoot(APP_AUTH_CONFIG)
  ],
  providers: [AuthGuardService],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Inside your login component use login method as the following:

login(): void {
    if (this.form.valid) {
      const loginData = this.form.getRawValue();
      this.authService.login(loginData.username, loginData.password).subscribe(() => {
        this.router.navigate(['/dashboard']);
      });
    }
  }

Token is automatically refreshed on secure endpoint calls.

Readme

Keywords

none

Package Sidebar

Install

npm i tbdevkit-ngauth

Weekly Downloads

1

Version

0.0.3

License

none

Unpacked Size

251 kB

Total Files

47

Last publish

Collaborators

  • npm