@corelink/login
v1.0.0
Published
## Installation
Downloads
31
Readme
Login module for Auth service
Installation
npm i -S @yca/auth @corelink/login
Usage
Add AuthModule
and LoginModule
to app.module.ts
.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AuthModule } from '@yca/auth';
import { LoginModule } from '@corelink/login';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
AuthModule.forRoot(),
LoginModule.forRoot({
root: 'http://auth.dev.corelink.vip',
headers: {
'x-corelink-auth-app-key': 'aeb8adf0-1487-11e9-8334-5b8340604e64',
}
}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
setup Auth
service.
import { Component } from '@angular/core';
import { Auth } from '@yca/auth';
import * as decoder from 'jwt-decode';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(public auth: Auth) {
auth.setup({
storage: {
get: k => Promise.resolve(localStorage.getItem(k)),
set: (k, v) => Promise.resolve(localStorage.setItem(k, v)),
clear: () => Promise.resolve(localStorage.clear()),
delete: k => Promise.resolve(localStorage.removeItem(k)),
},
decoder,
});
}
}
Use the component
<cl-login></cl-login>
Inputs and Outputs
@Input() title = 'Corelink Authorization';
@Input() usernamePlaceholder = 'Username';
@Input() passwordPlaceholder = 'Password';
@Input() buttonLabel = 'Login';
@Input() errorMsg = 'Invalid username or password';
@Output() success = new EventEmitter<void>();
@Output() fail = new EventEmitter<void>();
Or Use the service
import { LoginService } from '@corelink/login';
constructor(
private: ls: LoginService,
) { }
Methods
async basic(username: string, password: string);