Skip to content

Commit

Permalink
added userinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Nov 16, 2016
1 parent 2854db0 commit 56f826c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
15 changes: 8 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ module.exports = function(grunt) {
options: webpackConfig,
build: {
devtool: "source-map",
output: {
path: path.join(__dirname, "build"),
filename: 'lock.min.js'
output: {
path: path.join(__dirname, "build"),
filename: 'lock.min.js'
},
watch: false,
keepalive: false,
Expand All @@ -62,7 +62,7 @@ module.exports = function(grunt) {
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.UglifyJsPlugin({
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false, screw_ie8: true },
comments: false
}),
Expand All @@ -81,6 +81,7 @@ module.exports = function(grunt) {
},
dev: {
keepAlive: true,
port: 3000,
webpack: {
devtool: "eval",
debug: true
Expand All @@ -90,9 +91,9 @@ module.exports = function(grunt) {
keepAlive: true,
webpack: {
entry: './support/design/index.js',
output: {
path: path.join(__dirname, "build"),
filename: 'lock.design.js'
output: {
path: path.join(__dirname, "build"),
filename: 'lock.design.js'
},
devtool: "eval",
debug: true
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var domain = "YOUR_DOMAIN_AT.auth0.com";
var lock = new Auth0Lock(clientId, domain);

lock.on("authenticated", function(authResult) {
lock.getProfile(authResult.idToken, function(error, profile) {
lock.getUserInfo(authResult.accessToken, function(error, profile) {
if (error) {
// Handle error
return;
Expand All @@ -75,15 +75,24 @@ lock.on("authenticated", function(authResult) {

### getProfile(idToken, callback)

> *Note:* this method is soon to be deprecated, use `getUserInfo` instead.
Once the user has logged in and you are in possesion of and id token, you can obtain the profile with `getProfile`.

- **idToken {String}**: User id token.
- **callback {Function}**: Will be invoked after the user profile been retrieved.

### getUserInfo(accessToken, callback)

Once the user has logged in and you are in possesion of and access token, you can obtain the profile with `getUserInfo`.

- **accessToken {String}**: User access token.
- **callback {Function}**: Will be invoked after the user profile been retrieved.

#### Example

```js
lock.getProfile(idToken, function(error, profile) {
lock.getUserInfo(accessToken, function(error, profile) {
if (!error) {
alert("hello " + profile.name);
}
Expand Down
4 changes: 4 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export default class Base extends EventEmitter {
return webAPI.getProfile(this.id, token, cb);
}

getUserInfo(token, cb) {
return webAPI.getUserInfo(this.id, token, cb);
}

logout(query = {}) {
webAPI.signOut(this.id, query);
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class Auth0WebAPI {
return this.clients[lockID].getProfile(token, callback);
}

getUserInfo(lockID, token, callback) {
return this.clients[lockID].getUserInfo(token, callback);
}

getSSOData(lockID, ...args) {
return this.clients[lockID].getSSOData(...args);
}
Expand Down
3 changes: 3 additions & 0 deletions support/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

lock.on("authenticated", function(authResult) {
console.log(authResult);
lock.getUserInfo(authResult.accessToken, function(error, profile) {
console.log(error, profile);
});
});

lock.show();
Expand Down

0 comments on commit 56f826c

Please sign in to comment.