0.1.20 • Published 4 months ago

jattac.users.management.websdk v0.1.20

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

Jattac Computing User Management Service Web SDK

Usage

  1. Installation yarn add jattac.users.management.websdk

  2. 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' });```
  3. 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',
});
  1. 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

  1. Fetching Tenants
import { TenantsApiAccessor } from 'jattac.users.management.websdk';

const tenantsApiAccessor = new TenantsApiAccessor();

const tenants: ITenant[] = await tenantsApiAccessor.getTenantsPagedAsync({
  page: 1,
  pageSize: 20,
});
  1. 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.
0.1.20

4 months ago

0.1.19

4 months ago

0.1.14

4 months ago

0.1.15

4 months ago

0.1.16

4 months ago

0.1.17

4 months ago

0.1.18

4 months ago

0.1.10

6 months ago

0.1.11

6 months ago

0.1.12

6 months ago

0.1.13

6 months ago

0.0.11

6 months ago

0.1.0

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.8

6 months ago

0.1.7

6 months ago

0.1.9

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.0.10

12 months ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.1

1 year ago