facuxt / auth0-angular2-lock-sample

Quick demo for using Angular2 with Lock 10

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login

This example shows how to add Login/SignUp to your application using Lock widget.

You can read a quickstart for this sample here.

Getting Started

Rename the auth0.config.ts.example file in the app directory to auth0.config.ts and provide your Auth0 client ID and domain.

Install the npm packages described in the package.json and verify that it works:

# Install the dependencies
npm install

# Run
npm start

The npm start command first compiles the application, then simultaneously re-compiles and runs the lite-server. Both the compiler and the server watch for file changes.

Shut it down manually with Ctrl-C.

You're ready to write your application.

Important Snippets

1. Add lock dependency

/* ===== ./index.html ===== */
<head>
  ...
  <!-- Auth0 Lock script -->
  <script src="http://cdn.auth0.com/js/lock/10.2/lock.min.js"></script>
  ...
</head>

2. Login with lock

/* ===== app/auth.service.ts ===== */
@Injectable()
export class Auth {
  // Configure Auth0
  lock = new Auth0Lock('YOUR_CLIENT_ID', 'YOUR_DOMAIN', {});

  constructor() {
    // Add callback for lock `authenticated` event
    this.lock.on('authenticated', (authResult) => {
      localStorage.setItem('id_token', authResult.idToken);
    });
  }

  public login() {
    // Call the show method to display the widget.
    this.lock.show();
  };
  ...
}

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed JSON Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a free account in Auth0

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub or Microsoft Account to login.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

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

About

Quick demo for using Angular2 with Lock 10

License:MIT License


Languages

Language:TypeScript 41.3%Language:JavaScript 23.1%Language:CSS 20.8%Language:HTML 14.9%