Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated getProfile and added getUserInfo instead #726

Merged
merged 1 commit into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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();
Expand Down