1.0.1 • Published 6 years ago
@ranout/ngx-auth v1.0.1
Ngx Auth
An Angular module to manage authentication with this API: https://github.com/romain-jeannoutot/golang-restful-api
See a demo at: https://ngx-auth.ranout.xyz
Table of contents
Install
Install the module via npm:
npm i --save @ranout/ngx-auth
Usage
Import the AuthModule:
import { AuthModule } from '@ranout/ngx-auth';
@NgModule({
imports: [AuthModule.forRoot(YOUR_AUTH_API_URI)],
})
export class AppModule { }
What happens now ?
You now have access to AuthService (see more details in next section).
Transparently, an HttpInterceptor was added to automatically refresh the Access token when it expires.
Enjoy :)
Service
The AuthService contains three methods:
Login
this.authService.login(email, password, scopes).subscribe(success => {
// success = true if login success
});
Logout
this.authService.logout();
Is Authenticated
let authenticated = this.authService.isAuthenticated() // return true if user is authenticated