@gomus/auth
v0.1.6
Published
gomus - the auth framework
Downloads
12
Keywords
Readme
@gomus/auth
Token based authentication service for Angular2 with multiple user support. Angular2-Token works best with the devise token auth gem for Rails. Angular2-Token is currently in Beta. Any contribution is much appreciated.
This is a forked version of Angular2-Token which fixes some issues and supports angular 5.
Note: the A2tUiModule and oAuth are not yet implemented
Installation
To install this library, run:
$ npm install @gomus/auth --save
Consuming your library
Once you have published your library to npm, you can import your library in any Angular application by running:
$ npm install @gomus/auth
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { SampleModule } from '@gomus/auth';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify your library as an import
LibraryModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
The auth-guard can be customised as such:
@Injectable()
export class IntonationsAuthGuard extends AuthGuard {
constructor(auth: AuthService, router: Router, private config: ConfigService) {
super(auth, router);
}
userNotPresent(url: string): boolean {
localStorage.setItem('go-redirect-url', url);
if (new Date(this.config.getSetting('cutoff_date')) > new Date()) {
this.router.navigate(['/code']);
return false;
} else {
this.router.navigate(['/user']);
return false;
}
}
}
and editing your AppModule providers to include:
{provide: AuthGuard, useClass: IntonationsAuthGuard}
Development
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
License
MIT © See License