From 09cb15981cbe4df6b0d8c21304f4ed30520a0883 Mon Sep 17 00:00:00 2001 From: German Lena Date: Wed, 16 Nov 2016 14:36:43 -0300 Subject: [PATCH] added userinfo --- Gruntfile.js | 15 ++++++++------- README.md | 13 +++++++++++-- src/core.js | 4 ++++ src/core/web_api.js | 4 ++++ support/index.html | 3 +++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 846d54c8a..65839890a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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, @@ -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 }), @@ -81,6 +81,7 @@ module.exports = function(grunt) { }, dev: { keepAlive: true, + port: 3000, webpack: { devtool: "eval", debug: true @@ -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 diff --git a/README.md b/README.md index 6a7551258..05f6a6868 100644 --- a/README.md +++ b/README.md @@ -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; @@ -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); } diff --git a/src/core.js b/src/core.js index 22ac392a9..183066869 100644 --- a/src/core.js +++ b/src/core.js @@ -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); } diff --git a/src/core/web_api.js b/src/core/web_api.js index ad69ceedd..6e4949228 100644 --- a/src/core/web_api.js +++ b/src/core/web_api.js @@ -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); } diff --git a/support/index.html b/support/index.html index d6fd28e05..a364f47f5 100644 --- a/support/index.html +++ b/support/index.html @@ -23,6 +23,9 @@ lock.on("authenticated", function(authResult) { console.log(authResult); + lock.getUserInfo(authResult.accessToken, function(error, profile) { + console.log(error, profile); + }); }); lock.show();