Skip to content

Commit

Permalink
Merge pull request #141 from supertokens/fix/login-methods-api
Browse files Browse the repository at this point in the history
fix: Use tenants login method API for fetching tenants
  • Loading branch information
rishabhpoddar authored Mar 20, 2024
2 parents 0b6c1f5 + 6ba131a commit 2a9f5fc
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 281 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.11.0] - 2024-03-20

- Removes the tenants list API and uses the login methods API to get tenants and its login methods

## [0.10.5] - 2024-03-19

- Fixes UI bugs on search and Login methods section in userDetails page.
Expand Down
80 changes: 4 additions & 76 deletions api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,47 +1231,6 @@ paths:
type: array
items:
type: string
/dashboard/api/tenants/list:
get:
tags:
- Multitenancy
summary: Get all tenants created in the core
responses:
200:
description: Success
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: "OK"
coreConfig:
type: object
tenants:
type: array
items:
type: object
properties:
tenantId:
type: string
emailPassword:
type: object
properties:
enabled:
type: boolean
passwordless:
type: object
properties:
enabled:
type: boolean

thirdParty:
type: object
properties:
enabled:
type: boolean
/dashboard/api/tenants/login-methods:
get:
tags:
Expand All @@ -1295,41 +1254,10 @@ paths:
properties:
tenantId:
type: string
emailPassword:
type: object
properties:
enabled:
type: boolean
thirdPartyEmailPassword:
type: object
properties:
enabled:
type: boolean
nullable: true
passwordless:
type: object
properties:
enabled:
type: boolean
contactMethod:
type: string
enum: [PHONE, EMAIL, EMAIL_OR_PHONE]
nullable: true
thirdPartPasswordless:
type: object
properties:
enabled:
type: boolean
contactMethod:
type: string
enum: [PHONE, EMAIL, EMAIL_OR_PHONE]
nullable: true
nullable: true
thirdParty:
type: object
properties:
enabled:
type: boolean
firstFactors:
type: array
items:
type: string

/dashboard/api/userroles/roles:
get:
Expand Down
2 changes: 1 addition & 1 deletion build/static/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dashboard",
"version": "0.10.5",
"version": "0.11.0",
"private": true,
"dependencies": {
"@babel/core": "^7.16.0",
Expand Down
31 changes: 10 additions & 21 deletions src/api/tenants/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved.
/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
Expand All @@ -15,42 +15,31 @@

import { getApiUrl, useFetchData } from "../../utils";

export type PasswordlessContactMethod = "PHONE" | "EMAIL" | "EMAIL_OR_PHONE";

export type Tenant = {
tenantId: string;
emailPassword: {
enabled: boolean;
};
passwordless: {
enabled: boolean;
};
thirdParty: {
enabled: boolean;
};
firstFactors: string[];
};

type TenantsListResponse = {
type TenantsLoginMethodsResponse = {
status: "OK";
tenants: Tenant[];
};

type TenantsListService = {
fetchTenants: () => Promise<TenantsListResponse>;
fetchTenants: () => Promise<TenantsLoginMethodsResponse | undefined>;
};

export const useGetTenantsList = (): TenantsListService => {
export const useGetTenants = (): TenantsListService => {
const fetchData = useFetchData();
const fetchTenants = async (): Promise<TenantsListResponse> => {
const fetchTenants = async (): Promise<TenantsLoginMethodsResponse> => {
const response = await fetchData({
method: "GET",
url: getApiUrl("/api/tenants/list"),
url: getApiUrl("/api/tenants/login-methods"),
});

return response.ok
? await response.json()
: {
status: "OK",
tenants: [],
};
return response.ok ? await response.json() : undefined;
};

return {
Expand Down
64 changes: 0 additions & 64 deletions src/api/tenants/login-methods.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ export enum HTTPStatusCodes {
FORBIDDEN = 403,
NOT_FOUND = 404,
}

export const FactorIds = {
EMAILPASSWORD: "emailpassword",
OTP_EMAIL: "otp-email",
OTP_PHONE: "otp-phone",
LINK_EMAIL: "link-email",
LINK_PHONE: "link-phone",
THIRDPARTY: "thirdparty",
TOTP: "totp",
};
2 changes: 1 addition & 1 deletion src/ui/components/createUser/CreatePasswordlessUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import { useContext, useEffect, useState } from "react";
import { PasswordlessContactMethod } from "../../../api/tenants/login-methods";
import { PasswordlessContactMethod } from "../../../api/tenants/list";
import useCreateUserService, { CreatePasswordlessUserPayload } from "../../../api/user/create";
import { getApiUrl, getImageUrl } from "../../../utils";
import { PopupContentContext } from "../../contexts/PopupContentContext";
Expand Down
Loading

0 comments on commit 2a9f5fc

Please sign in to comment.