This interface is used to work with an external portal in a workspace.

Hierarchy

  • Portal

Properties

Readonly namespace

namespace: string

Code of the workspace that the portal is created in.

Readonly profiles

Manage user profiles.

Readonly published

published: boolean

If the portal is published. After being published, the portal becomes available to the external users.

Methods

addProfile

  • Deprecated. Provide the specified profile access to the portal.

    Example:

    const user = await System.users.search().first();
    if (user) { 
        const profile = await Namespace.portal.profiles. getByUser(user); 
        if (profile) { 
            await Namespace.portal. addProfile(profile); 
        } 
    } 
    
    deprecated

    Use the grantAccess() method.

    Parameters

    Returns Promise<void>

addUser

  • Create a portal user.

    This method creates a portal user from an existing profile with the Invited status. At the moment, a profile can only be stored in the ** External users** system collection (_user_profiles). The method returns errors with the following codes: — 400: the profile is not an item of the ** External users** collection. — 409: a user with the specified email or OAuth2 authorization settings already exists. — 412: there are no available portal licenses. — 500 in all other cases.

    Parameters

    • portalUserProfile: ApplicationItemRef<UserProfileItemData, ItemData>

      User profile. Example:

      const newPortalUser = Global.ns. _system_catalogs.app._user_profiles.create();
      newPortalUser.data.email =  'user.email@email.com'; 
      newPortalUser.data.fullname = <TFullName>{ 
           firstname: 'firstname', 
          middlename: 'middlename', 
          lastname:  'lastname', 
      }; 
      await newPortalUser.save(); 
      const user = await Namespace. portal.addUser( 
          newPortalUser, 
      ); 
      

    Returns Promise<UserItem>

addUserWithoutConfirmation

  • Add a portal user using an existing profile with OAuth2 authorization.

    Important: Once a user has been created, the OAuth2 authorization credentials cannot be changed. The method creates a new portal user using their profile and adds the credentials for OAuth2 authorization. Currently, the profile can only be located in the system collection External users (_user_profiles). The method returns errors with the following codes: — 400: no OAuth2 authorization parameters are passed or the profile is not an item of the “External Users” collection. — 409: a user with the specified email or OAuth2 authorization settings already exists. — 412: there are no available portal licenses. — 500 in all other cases.

    Parameters

    • portalUserProfile: ApplicationItemRef<ItemData, ItemData>

      User profile.

    • auth: AuthData

      Available methods for external authorization. Example:

      const newPortalUser = Global.ns._system_catalogs.app._user_profiles. create();
      newPortalUser.data.email = 'user.email@email.com';  
      newPortalUser.data.fullname = <TFullName>{ 
          firstname: 'firstname',  
          middlename: 'middlename', 
          lastname: 'lastname', 
      }; 
      await  newPortalUser.save(); 
      const oAuth2Records: OAuth2Record[] = [ 
           <OAuth2Record>{ 
              providerId: 'a0524184-737e-4680-a549-1e4e94c01707',  
              externalId: 'abcd123', 
          } 
      ] 
      const auth: AuthData = <AuthData>{  
          oauth2: oAuth2Records, 
      } 
      await Namespace.portal. addUserWithoutConfirmation( 
          newPortalUser, 
          auth, 
      ); 
      

    Returns Promise<void>

denyAccess

  • Deny the specified profile access to the portal.

    Example:

    const user = await System.users.search().first();
    if (user) { 
        const profile = await Namespace.portal.profiles. getByUser(user); 
        if (profile) { 
            await Namespace.portal. denyAccess(profile); 
        } 
    } 
    

    Parameters

    Returns Promise<void>

generateELMAAppUrl

  • generateELMAAppUrl(withAuthToken?: undefined | false | true): Promise<string>
  • Generate a link to the portal for the mobile app or desktop app.

    If true is passed to the withAuthToken parameter, a short-lived authentication token for the current user is added to the generated link, allowing for automatic sign-in to the target portal (with no additional authentication procedures). The method is available only in client-side scripts. Example:

    const ELMAAppUrl = await Namespace.portal. generateELMAAppUrl();
    

    Parameters

    • Optional withAuthToken: undefined | false | true

      Including authentication token in link flag (the default value is false).

    Returns Promise<string>

getPages

  • Get a list of portal pages in the current workspace.

    Example:

    const pages = await Namespace.portal.getPages();
    

    Returns Promise<PortalPageInfo[]>

getSettings

  • Get portal settings.

    Example:

    const settings = await Namespace.portal. getSettings();
    

    Returns Promise<PortalSettings>

grantAccess

  • Grant the specified profile access to the portal.

    Example:

    const user = await System.users.search().first();
    if (user) { 
        const profile = await Namespace.portal.profiles. getByUser(user); 
        if (profile) { 
            await Namespace.portal. grantAccess(profile); 
        } 
    } 
    

    Parameters

    Returns Promise<void>

removeProfile

  • Deprecated. Deny a profile access to the portal.

    Example:

    const user = await System.users.search().first();
    if (user) { 
        const profile = await Namespace.portal.profiles. getByUser(user); 
        if (profile) { 
            await Namespace.portal. removeProfile(profile); 
        } 
    } 
    
    deprecated

    Use the denyAccess() method.

    Parameters

    Returns Promise<void>

setPortalUserAsInternal

  • setPortalUserAsInternal(portalUser: UserItemRef, _unsafe_ignore_oauth?: undefined | false | true): Promise<void>
  • Make a portal user an internal user of the system.

    Example:

    const portalUser = await Namespace.portal.profiles. getUser(profile);
    await Namespace.portal. setPortalUserAsInternal(portalUser); 
    

    Parameters

    • portalUser: UserItemRef

      Portal user.

    • Optional _unsafe_ignore_oauth: undefined | false | true

      Dangerous option. Use with caution. Allows ignoring OAuth provider settings. The default value is false.

    Returns Promise<void>

signupUrl

  • Get a link for the registration of an external user.

    You can create a URL for registration with contact details confirmation:

    if (Context.data.user_profile) {
        const inviteUrl = await  Namespace.portal.signupUrl(Context.data.user_profile); 
    } 
    

    To create a URL without contact details confirmation and send the URL to a designated person, you need to pass the withSign parameter:

    if  (Context.data.user_profile) {
        const inviteUrl = await Namespace.portal. signupUrl(Context.data.user_profile, { 
            withSign: true 
        }); 
    }  
    

    To refresh a URL created earlier, pass the refresh parameter:

    if (Context.data.user_profile) {
        const inviteUrl = await  Namespace.portal.signupUrl(Context.data.user_profile, { 
            refresh:  true, 
        }); 
    } 
    

    Type parameters

    Parameters

    Returns Promise<string>