jattac.users.management.websdk v0.1.20
Jattac Computing User Management Service Web SDK
Usage
Installation
yarn add jattac.users.management.websdk
Configuration At the entry point of your application configure library as follows
import { JattacUsersManagementConfiguration } from "jattac.users.management.websdk"; new JattacUsersManagementConfiguration({ url: 'localhost:5141', apiKey: 'your-api-key' });```
Create Account
import { UsersApiAccessor } from 'jattac.users.management.websdk';
const usersApiAccessor = new UsersApiAccessor();
const result = await usersApiAccessor.createAccountAsync({
isAdmin: true,
password: 'password',
passwordConfirmation: 'password',
username: 'alice@example.com',
phoneNumber: '+254777777777',
});
- Signing In
import { UsersApiAccessor } from 'jattac.users.management.websdk';
const usersApiAccessor = new UsersApiAccessor();
const result = await usersApiAccessor.signInAsync({
password: 'password',
username: 'alice@example.com',
});
The returned result from sign in returns a JWT token
- Fetching Tenants
import { TenantsApiAccessor } from 'jattac.users.management.websdk';
const tenantsApiAccessor = new TenantsApiAccessor();
const tenants: ITenant[] = await tenantsApiAccessor.getTenantsPagedAsync({
page: 1,
pageSize: 20,
});
- Checking If Your Have At Least One User Account Configured
Overview
The hasAtLeastOneUserAsync
method is designed to check whether a tenant has at least one account. It operates asynchronously, returning a Promise that resolves to a boolean value indicating whether the user has at least one account.
This method is important in that it allows you to determine if you need to create your initial admin account.
Usage
To use this function, call it in your code and await the Promise for the result. It communicates with an endpoint internally to determine the presence of at least one account for your specified tenant account.
import { UsersApiAccessor } from 'jattac.users.management.websdk';
const usersApiAccessor = new UsersApiAccessor();
const hasAccount = await usersApiAccessor.hasAtLeastOneUserAsync();
console.log(hasAccount); // true or false
Return Value
The function returns a Promise that resolves to a boolean value:
true
: Indicates that the tenant has at least one account.false
: Indicates that the tenant does not have any accounts.
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago