Merge pull request #21815 from scamden/patch-1

add types for checkSession method for auth0-lock
This commit is contained in:
Mine Starks
2017-12-11 09:17:41 -08:00
committed by GitHub
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -10,6 +10,17 @@ lock.show();
lock.hide();
lock.logout(() => {});
lock.checkSession({}, function(error: auth0.Auth0Error, authResult: AuthResult): void {
if (error || !authResult) {
lock.show();
} else {
// user has an active session, so we can use the accessToken directly.
lock.getUserInfo(authResult.accessToken, function(error, profile) {
console.log(error, profile);
});
}
});
// Show supports UI arguments
const showOptions : Auth0LockShowOptions = {
@@ -37,7 +48,7 @@ lock.show(showOptions);
// "on" event-driven example
lock.on("authenticated", function(authResult : any) {
lock.on("authenticated", function(authResult: AuthResult) {
lock.getProfile(authResult.idToken, function(error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) {
if (error) {
// Handle error
@@ -49,7 +60,7 @@ lock.on("authenticated", function(authResult : any) {
});
});
lock.on("authenticated", function(authResult : any) {
lock.on("authenticated", function(authResult: AuthResult) {
lock.getUserInfo(authResult.accessToken, function(error, profile) {
if (error) {
// Handle error
+1
View File
@@ -154,6 +154,7 @@ interface Auth0LockStatic {
// deprecated
getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
checkSession(options: any, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void;
// https://github.com/auth0/lock#resumeauthhash-callback
resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void;
show(options?: Auth0LockShowOptions): void;