1.0.0 • Published 6 years ago

c247-login-component v1.0.0

Weekly downloads
5
License
MIT
Repository
-
Last release
6 years ago

c247-login-component is an angular (2+) login component. It features a responsive login page and auto saves a JSON web token to sessionStorage.token on a successful login attempt.

Installation:

npm install --save c247-login-component

This package has a peer dependency on bootstrap. Here's how to install it:

npm install --save bootstrap
/* in src/styles.css */
@import '~bootstrap/dist/css/bootstrap.min.css';

Usage:

Add the module to your module.ts

import { LoginPageModule } from 'c247-login-component';

@NgModule({
 ...
 imports: [
    LoginPageModule
 ]
});
<!-- api.example.com/login will receive JSON in the form { email, password } when a user tries to login -->
<app-login-component [loginUrl]="'api.example.com/login'" [onSuccess]="onSuccess"></app-login-component>

Now you'll need to define the onSuccess handler:

  // apiData will be whatever is returned from `api.example.com/login` after a successful login attempt
  // httpResponse is the full http response of `api.example.com/login`
  // calling `logout` will logout the user, removing the jwt from sessionStorage
  onSuccess(apiData, logout: Function, httpResponse: Response) {
    // do something
  }