1.1.0 • Published 6 years ago

authmodule-ionic3-angular6 v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

AuthModule for Ionic 3 & Angular 6

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)
        })
    ]
    ...
})

########## 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.

token() : Returns the session token.

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();

        @Output()
        changePage: EventEmitter<boolean> = new EventEmitter();

auth-app-register

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

        @Output()
        changePage: EventEmitter<boolean> = new EventEmitter();

auth-app-change-password

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

        @Output()
        changePage: EventEmitter<boolean> = new EventEmitter();
1.1.0

6 years ago