1.0.0 • Published 6 months ago

intellect-authentication-services-module v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

IntellectAuthenticationServicesModule

This project was generated with Angular CLI version 1.6.8.

Installation

yarn add "@igtb-digital/intellect-authentication-services-module"

Usage

Importing in Root Module

import { IntellectAuthenticationServiceModule, IntellectAuthConfig } from '@igtb-digital/intellect-authentication-services-module';

const authConfig: IntellectAuthConfig = {
  clientId: '',
  issuer: '',
  oidc: '',
  redirectUri: '',
  scope: ''
}

@NgModule({
  imports: [
    IntellectAuthenticationServiceModule.forRoot(authConfig)
  ],
  declarations: [
    AppComponent,
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule {
}

Importing in feature module

import { IntellectAuthenticationServiceModule, IntellectAuthConfig } from '@igtb-digital/intellect-authentication-services-module';

@NgModule({
  imports: [
    IntellectAuthenticationServiceModule
  ],
  declarations: [
    FeatureComponent,
  ],

})
export class FeatureModule {
}

Implementing a Login

After you've configured the module, you just have to call login function using AuthenticationService

import { Component } from '@angular/core';
import { AuthenticationServices } from '@igtb-digital/intellect-authentication-services-module';

@Component({
    templateUrl: "app/home.html"
})
export class HomeComponent {

    constructor(private authenticationServices: AuthenticationServices) {
    }

    public login(email: string, password: string) {
        this.authenticationServices.login(email,password);
    }

    public logoff() {
        this.authenticationServices.logOut();
    }

    public get userInfo() {
        authenticationServices.getUserInfo();
    }

}

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate --app=auth-services component component-name to generate a new component in authentication-service module. You can also use ng generate --app=auth-services directive|pipe|service|class|guard|interface|enum|module.

Build Module

Run npm run build:module to build the module. The build artifacts will be stored in the modules/intellect-authentication-services-module/dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Publish Module

  1. Run npm run release-* "*" can be major|minor|patch|beta|alpha based on changes
  2. build the module using npm run build:module
  3. git push and publish to npm npm run publish

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.