mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #21815 from scamden/patch-1
add types for checkSession method for auth0-lock
This commit is contained in:
@@ -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
|
||||
|
||||
Vendored
+1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user