Edit in GitHubLog an issue

External module: user

API to request user-specific information such as IMS organization, IMS profile, access token, tenant, etc. It also provides solutions with other capabilities such as notifying the shell that the session has expired and configuring a logout URL to expire custom sessions.

Import:

Copied to your clipboard
import user from '@adobe/exc-app/user';

Default export:

UserApi

Usage:

Below is an example of how to get various attributes associated to the user:

Copied to your clipboard
1import user from '@adobe/exc-app/user';
2
3const [org, name, orgs, token, profile, locale, subOrg, tenant, languages] = await Promise.all([
4 user.get('imsOrg'),
5 user.get('imsOrgName'),
6 user.get('imsOrgs'),
7 user.get('imsToken'),
8 user.get('imsProfile'),
9 user.get('locale'),
10 user.get('subOrg'),
11 user.get('tenant'),
12 user.get('preferredLanguages')
13]);

Receiving updates#

You can also listen for updates on the requested data by listening to specific change events.

These change events are emitted from the api that the data is requested from. For example, if a user calls await user.get('locale'); they must listen for the change event on user.on('change:locale'). If a user calls await user.get('imsOrg') they must listen for the change event on user.on('change:imsOrg'). Here is a more detailed example of how the promise api and change events can be used to keep track of specific values from the config:

Copied to your clipboard
1import user from '@adobe/exc-app/user';
2
3constructor() {
4 this.state = {org: null, shell: {}};
5
6 user.on('change:imsOrg', (org) => {
7 this.setState({org});
8 });
9}
10
11async componentDidMount() {
12 const org = await user.get('imsOrg');
13 this.setState({org});
14}

Index#

Interfaces#

  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.