1.0.15 • Published 8 years ago

auth0-angular2 v1.0.15

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
8 years ago

NPM version License Downloads

Auth0 Angular2

Auth0 Angular2 library helps you easily integrate Auth0 with your Angular 2 application. Auth0 Angular2 is written in TypeScript.

Installation

npm install auth0-angular2

and in your index.html

<script src="http://cdn.auth0.com/js/lock/10.4/lock.min.js"></script>

(If you know how to include the Auth0 Lock dependency in the library, please contribute!)

Using provideAuthService

Add provideAuthService to the providers array in your @NgModule.

import { provideAuthService } from 'auth0-angular2';

...

@NgModule({
  ...
  
  providers: [
    provideAuthService('clientId', 'domain')
  ],
  
  ...
})

After a successful login, Auth0 Lock by default redirects to the path that triggers the Lock and you may override it by providing a /redirectPath parameter. You may also provide a /homePath parameter to indicate where to route the application to after a successful login.

provideAuthService('clientId', 'domain', '/homePath', '/redirectPath')

Authenticating users

Using an authentication route guard as an example

import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from 'auth0-angular2';

@Injectable()
export class AuthGuard implements CanActivate {
  constructor(private auth: AuthService) { }
  
  canActivate() {
    if(this.auth.loginIfNotAuthenticated()){
      return false;
    }
    
    return true;
  }
}

Sending authenticated HTTP requests

Please use angular2-jwt directly, which is already installed with this library. (More features on sending authenticated HTTP requests are currently under development.)

Contributing

Pull requests are welcome!

Development

npm install

and

npm run prepublish to compile.

Browser Compatibility

We currently ensure browser compatibility in Chrome only.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section.

Author

Cimpress MCP

License

This project is licensed under the Apache 2.0 license. See the LICENSE file for more info.

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago