title | name | alias | language | framework | image | tags | snippets | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Meteor Tutorial |
Meteor |
|
|
|
/media/platforms/meteor.png |
|
|
<%= include('../_includes/_package', { pkgRepo: 'meteor-auth0', pkgBranch: 'master', pkgPath: 'examples/auth0-meteor-sample', pkgFilePath: null, pkgType: 'server' + account.clientParam }) %>
If you have an existing application, follow the steps below.
Install our Meteor package from Atmosphere on your Meteor application by running this command on your project folder.
${snippet(meta.snippets.dependencies)}
Note: this package is designed to work with Meteor 1.2.1, so please run meteor update
in the root of your project if you're using an older version.
Create an .env
file on the root of your application folder, and configure it with the following contents:
${snippet(meta.snippets.setup)}
Our meteor package reads this information and creates a Lock instance with these settings.
To implement the login, call the .show()
method of Auth0's lock
instance on the client of your Meteor project.
${snippet(meta.snippets.use)}
In this case we are using a Meteor Template called Auth0Login
.
To discover all the available arguments for lock.show
, see .show([options, callback]).
You can retrieve information about the user's profile using the currentUser
helper. The information will be under currentUser.services.auth0
.
#app.html
<template name="Auth0Login">
{{#if currentUser}}
<div>Your name is: <b>{{currentUser.services.auth0.name}}</b></div>
<button class="logout">Log Out</button>
{{else}}
<button class="login">Log In</button>
{{/if}}
</template>
You can access the user profile from the server through the Meteor.user()
global getter, the information will be under the services.auth0
object.
var userName = Meteor.user().services.auth0.name;
To discover all the available properties of a user's profile, see user-profile. Note that the properties available depend on the social provider used.
To log out you can just call Meteor.logout();
on the client side of your application.
'click button.logout': function () {
Meteor.logout();
}
You have completed the implementation of Login and Signup with Auth0 and Meteor.