function validateUser(userInfo) {
    this.oktaRecord = userInfo

    client.enterprise.getUsers({ "external_app_user_id": this.oktaRecord.sub })
    .then((result) => {
      if (result.total_count > 0) {
        // User found, get user ID and fetch user token
        this.userId = result.entries[0].id;
        this.userClient = sdk.getAppAuthClient('user', this.userId);

        this.userClient.users.get(this.userClient.CURRENT_USER_ID)
        .then(currentUser => {
          console.log(currentUser);
      	});
        
      } else {
        // User not found - create user
        this.createUser();
      }
    });
  }
// Validate whether an app user already exists for the Okta ID
Validate whether an app user already exists for the Okta ID
Validate whether an app user already exists for the Okta ID
function validateUser(userInfo) {
    this.oktaRecord = userInfo
    client.enterprise.getUsers({ "external_app_user_id": this.oktaRecord.sub })
    .then((result) => {
      if (result.total_count > 0) {
        this.userId = result.entries[0].id;
        this.userClient = sdk.getAppAuthClient('user', this.userId);
        this.userClient.users.get(this.userClient.CURRENT_USER_ID)
        .then(currentUser => {
          console.log(currentUser);
      	});
      } else {
        this.createUser();
      }
    });
  }
function validateUser ( userInfo ) { this . oktaRecord = userInfo client . enterprise . getUsers ( { "external_app_user_id" : this . oktaRecord . sub } ) . then ( ( result ) => { if ( result . total_count > 0 ) { this . userId = result . entries [ 0 ] . id ; this . userClient = sdk . getAppAuthClient ( 'user' , this . userId ) ; this . userClient . users . get ( this . userClient . CURRENT_USER_ID ) . then ( currentUser => { console . log ( currentUser ) ; } ) ; } else { this . createUser ( ) ; } } ) ; }
Validate whether an app user already exists for the Okta ID
Validate whether an app user already exists for the Okta ID
// User found, get user ID and fetch user token // User not found - create user