Genesis User
![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)
foundation-user
provides the User singleton, which always exists in either an
anonymous or authenticated mode.
Get User reference
User is a singleton. You can access it via the DI container.
import { User } from '@genesislcap/foundation-user';
...
@User private user: User
...or via a utility if your app is not using decorators or the DI container.
import { getUser } from '@genesislcap/foundation-user';
...
private user = getUser();
User properties are decorated with @observable
, meaning in FAST terms it's reactive, and you can bind to properties
directly. For example, this.user.isAuthenticated
. However, you can also monitor the user's authentication status using
an event listener.
import type { UserAuthenticationChangeEvent } from '@genesislcap/foundation-user';
...
const unsubscribeUser = this.user.addAuthenticationChangeListener((event: UserAuthenticationChangeEvent) => {
console.log('User authenticated?', event.detail);
});
See the User API Docs for more information.
Installation
To enable this module in your application, follow the steps below.
- Add
@genesislcap/foundation-user
as a dependency in your package.json
file. Whenever you change the dependencies of your project, ensure you run the $ npm run bootstrap
command again. You can find more information in the package.json basics page.
{
...
"dependencies": {
...
"@genesislcap/foundation-user": "latest"
...
},
...
}
License
Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact Genesis Global for more details.
Licensed components
Genesis low-code platform