From 264995d8b9f37557dd7901ec495fc0723ec50bc6 Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Fri, 6 Jan 2017 19:28:51 -0600 Subject: [PATCH] Add getUserInfo based on auth0-lock documentation on Github (#13823) --- auth0-lock/auth0.lock-tests.ts | 12 ++++++++++++ auth0-lock/index.d.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/auth0-lock/auth0.lock-tests.ts b/auth0-lock/auth0.lock-tests.ts index bba2fc8228..cd51950c6a 100644 --- a/auth0-lock/auth0.lock-tests.ts +++ b/auth0-lock/auth0.lock-tests.ts @@ -26,6 +26,18 @@ lock.on("authenticated", function(authResult : any) { }); }); +lock.on("authenticated", function(authResult : any) { + lock.getUserInfo(authResult.accessToken, function(error, profile) { + if (error) { + // Handle error + return; + } + + localStorage.setItem("idToken", authResult.idToken); + localStorage.setItem("profile", JSON.stringify(profile)); + }); +}); + // test theme diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index 1a05d3f913..e2964d287c 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -107,6 +107,8 @@ interface Auth0LockStatic { new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic; getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; + getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; + show(): void; hide(): void; logout(query: any): void;