authmodule-angular6-module-example
TypeScript icon, indicating that this package has built-in type declarations

1.0.24 • Public • Published

CONFIGURATION

########## Import in app.module.ts

import { AuthenticationModule } from 'authmodule-angular6-module-example';

@NgModule({
    ...
    imports: [
        AuthenticationModule.forRoot({
            apiUrl: 'http://localhost:3000', # API Url
            loginEndpoint: 'users'  # [users or admin] endPoint in Loopback (for http://localhost:3000/users/login),
            createAccount: 'register', # route for register page *optional
            loginAccount: 'login' #route for login page *optional
        })
    ]
    ...
})

########## To use in a component:

import { AuthenticationService } from 'authmodule-angular6-module-example';
...
constructor(private authenticationService: AuthenticationService) {
    console.log('from authenticationService', this.authenticationService.isAuthenticated());
}

########## Exposed Methods

isAuthenticated() : Returns a boolean with the isLoggedIn value.

login(values: CredentialsInterface): Receive a credentials interface (email: string and password: string) and 
    if is a login success set the token and isLoggedIn in localstorage and variable isLoggedIn as true.

logout(): void: Remove token and isLoggedIn from localStorage and the variable isLoggedIn set to false.

########## Component Selectors

auth-app-login

        @Output()
        submit: EventEmitter<any> = new EventEmitter();

auth-app-register

        @Output()
        submit: EventEmitter<any> = new EventEmitter();

auth-app-change-password

        @Output()
        submit: EventEmitter<any> = new EventEmitter();

Package Sidebar

Install

npm i authmodule-angular6-module-example

Weekly Downloads

0

Version

1.0.24

License

MIT

Unpacked Size

224 kB

Total Files

85

Last publish

Collaborators

  • cesaralonso