Skip to content

Commit

Permalink
fix: dashboard multitenancy updates (#623)
Browse files Browse the repository at this point in the history
* fix: dashboard updates

* fix: pr comments
  • Loading branch information
sattvikc authored Jul 5, 2023
1 parent ab8de59 commit 4564d9d
Show file tree
Hide file tree
Showing 68 changed files with 403 additions and 116 deletions.
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/analytics.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { APIInterface, APIOptions } from "../types";
export declare type Response = {
status: "OK";
};
export default function analyticsPost(_: APIInterface, options: APIOptions, __: any): Promise<Response>;
export default function analyticsPost(_: APIInterface, ___: string, options: APIOptions, __: any): Promise<Response>;
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const normalisedURLPath_1 = __importDefault(require("../../../normalisedURLPath"
const version_1 = require("../../../version");
const error_1 = __importDefault(require("../../../error"));
const axios_1 = __importDefault(require("axios"));
function analyticsPost(_, options, __) {
function analyticsPost(_, ___, options, __) {
return __awaiter(this, void 0, void 0, function* () {
// If telemetry is disabled, dont send any event
if (!supertokens_1.default.getInstanceOrThrowError().telemetryEnabled) {
Expand Down
1 change: 1 addition & 0 deletions lib/build/recipe/dashboard/api/apiKeyProtector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { APIFunction, APIInterface, APIOptions } from "../types";
export default function apiKeyProtector(
apiImplementation: APIInterface,
tenantId: string,
options: APIOptions,
apiFunction: APIFunction,
userContext: any
Expand Down
4 changes: 2 additions & 2 deletions lib/build/recipe/dashboard/api/apiKeyProtector.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var __awaiter =
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
function apiKeyProtector(apiImplementation, options, apiFunction, userContext) {
function apiKeyProtector(apiImplementation, tenantId, options, apiFunction, userContext) {
return __awaiter(this, void 0, void 0, function* () {
const shouldAllowAccess = yield options.recipeImplementation.shouldAllowAccess({
req: options.req,
Expand All @@ -43,7 +43,7 @@ function apiKeyProtector(apiImplementation, options, apiFunction, userContext) {
utils_1.sendUnauthorisedAccess(options.res);
return true;
}
const response = yield apiFunction(apiImplementation, options, userContext);
const response = yield apiFunction(apiImplementation, tenantId, options, userContext);
options.res.sendJSONResponse(response);
return true;
});
Expand Down
23 changes: 23 additions & 0 deletions lib/build/recipe/dashboard/api/listTenants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-nocheck
import { APIInterface, APIOptions } from "../types";
import { ProviderConfig } from "../../thirdparty/types";
export declare type Response = {
status: "OK";
tenants: {
tenantId: string;
emailPassword: {
enabled: boolean;
};
passwordless: {
enabled: boolean;
};
thirdParty: {
enabled: boolean;
providers: ProviderConfig[];
};
coreConfig: {
[key: string]: any;
};
}[];
};
export default function listTenants(_: APIInterface, __: string, ___: APIOptions, userContext: any): Promise<Response>;
46 changes: 46 additions & 0 deletions lib/build/recipe/dashboard/api/listTenants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use strict";
var __awaiter =
(this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P
? value
: new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const multitenancy_1 = __importDefault(require("../../multitenancy"));
function listTenants(_, __, ___, userContext) {
return __awaiter(this, void 0, void 0, function* () {
let tenantsRes = yield multitenancy_1.default.listAllTenants(userContext);
return tenantsRes;
});
}
exports.default = listTenants;
7 changes: 6 additions & 1 deletion lib/build/recipe/dashboard/api/search/tagsGet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ declare type TagsResponse = {
status: "OK";
tags: string[];
};
export declare const getSearchTags: (_: APIInterface, options: APIOptions, __: any) => Promise<TagsResponse>;
export declare const getSearchTags: (
_: APIInterface,
___: string,
options: APIOptions,
__: any
) => Promise<TagsResponse>;
export {};
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/search/tagsGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getSearchTags = void 0;
const querier_1 = require("../../../../querier");
const normalisedURLPath_1 = __importDefault(require("../../../../normalisedURLPath"));
const getSearchTags = (_, options, __) =>
const getSearchTags = (_, ___, options, __) =>
__awaiter(void 0, void 0, void 0, function* () {
let querier = querier_1.Querier.getNewInstanceOrThrowError(options.recipeId);
let tagsResponse = yield querier.sendGetRequest(new normalisedURLPath_1.default("/user/search/tags"), {});
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/signOut.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-nocheck
import { APIInterface, APIOptions } from "../types";
export default function signOut(_: APIInterface, options: APIOptions, __: any): Promise<boolean>;
export default function signOut(_: APIInterface, ___: string, options: APIOptions, __: any): Promise<boolean>;
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/signOut.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils");
const querier_1 = require("../../../querier");
const normalisedURLPath_1 = __importDefault(require("../../../normalisedURLPath"));
function signOut(_, options, __) {
function signOut(_, ___, options, __) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (options.config.authMode === "api-key") {
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/userdetails/userDelete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { APIInterface, APIOptions } from "../../types";
declare type Response = {
status: "OK";
};
export declare const userDelete: (_: APIInterface, options: APIOptions, __: any) => Promise<Response>;
export declare const userDelete: (_: APIInterface, ___: string, options: APIOptions, __: any) => Promise<Response>;
export {};
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/userdetails/userDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.userDelete = void 0;
const supertokens_1 = __importDefault(require("../../../../supertokens"));
const error_1 = __importDefault(require("../../../../error"));
const userDelete = (_, options, __) =>
const userDelete = (_, ___, options, __) =>
__awaiter(void 0, void 0, void 0, function* () {
const userId = options.req.getKeyValueFromQuery("userId");
if (userId === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.userEmailverifyGet = void 0;
const error_1 = __importDefault(require("../../../../error"));
const recipe_1 = __importDefault(require("../../../emailverification/recipe"));
const emailverification_1 = __importDefault(require("../../../emailverification"));
const userEmailverifyGet = (_, options, userContext) =>
const userEmailverifyGet = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const req = options.req;
const userId = req.getKeyValueFromQuery("userId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ import { APIInterface, APIOptions } from "../../types";
declare type Response = {
status: "OK";
};
export declare const userEmailVerifyPut: (_: APIInterface, options: APIOptions, userContext: any) => Promise<Response>;
export declare const userEmailVerifyPut: (
_: APIInterface,
tenantId: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.userEmailVerifyPut = void 0;
const error_1 = __importDefault(require("../../../../error"));
const emailverification_1 = __importDefault(require("../../../emailverification"));
const userEmailVerifyPut = (_, options, userContext) =>
const userEmailVerifyPut = (_, tenantId, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const userId = requestBody.userId;
Expand All @@ -60,6 +60,7 @@ const userEmailVerifyPut = (_, options, userContext) =>
const tokenResponse = yield emailverification_1.default.createEmailVerificationToken(
userId,
undefined,
tenantId,
userContext
);
if (tokenResponse.status === "EMAIL_ALREADY_VERIFIED_ERROR") {
Expand All @@ -69,6 +70,7 @@ const userEmailVerifyPut = (_, options, userContext) =>
}
const verifyResponse = yield emailverification_1.default.verifyEmailUsingToken(
tokenResponse.token,
tenantId,
userContext
);
if (verifyResponse.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare type Response = {
};
export declare const userEmailVerifyTokenPost: (
_: APIInterface,
tenantId: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const error_1 = __importDefault(require("../../../../error"));
const emailverification_1 = __importDefault(require("../../../emailverification"));
const recipe_1 = __importDefault(require("../../../emailverification/recipe"));
const utils_1 = require("../../../emailverification/utils");
const userEmailVerifyTokenPost = (_, options, userContext) =>
const userEmailVerifyTokenPost = (_, tenantId, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const userId = requestBody.userId;
Expand All @@ -58,14 +58,14 @@ const userEmailVerifyTokenPost = (_, options, userContext) =>
let emailVerificationToken = yield emailverification_1.default.createEmailVerificationToken(
userId,
undefined,
tenantId,
userContext
);
if (emailVerificationToken.status === "EMAIL_ALREADY_VERIFIED_ERROR") {
return {
status: "EMAIL_ALREADY_VERIFIED_ERROR",
};
}
const tenantId = "";
let emailVerifyLink = utils_1.getEmailVerifyLink({
appInfo: options.appInfo,
token: emailVerificationToken.token,
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/userdetails/userGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const error_1 = __importDefault(require("../../../../error"));
const utils_1 = require("../../utils");
const recipe_1 = __importDefault(require("../../../usermetadata/recipe"));
const usermetadata_1 = __importDefault(require("../../../usermetadata"));
const userGet = (_, options, userContext) =>
const userGet = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const userId = options.req.getKeyValueFromQuery("userId");
const recipeId = options.req.getKeyValueFromQuery("recipeId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.userMetaDataGet = void 0;
const error_1 = __importDefault(require("../../../../error"));
const recipe_1 = __importDefault(require("../../../usermetadata/recipe"));
const usermetadata_1 = __importDefault(require("../../../usermetadata"));
const userMetaDataGet = (_, options, userContext) =>
const userMetaDataGet = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const userId = options.req.getKeyValueFromQuery("userId");
if (userId === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ import { APIInterface, APIOptions } from "../../types";
declare type Response = {
status: "OK";
};
export declare const userMetadataPut: (_: APIInterface, options: APIOptions, userContext: any) => Promise<Response>;
export declare const userMetadataPut: (
_: APIInterface,
___: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.userMetadataPut = void 0;
const recipe_1 = __importDefault(require("../../../usermetadata/recipe"));
const usermetadata_1 = __importDefault(require("../../../usermetadata"));
const error_1 = __importDefault(require("../../../../error"));
const userMetadataPut = (_, options, userContext) =>
const userMetadataPut = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const userId = requestBody.userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ declare type Response =
status: "INVALID_PASSWORD_ERROR";
error: string;
};
export declare const userPasswordPut: (_: APIInterface, options: APIOptions, userContext: any) => Promise<Response>;
export declare const userPasswordPut: (
_: APIInterface,
tenantId: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
export {};
11 changes: 9 additions & 2 deletions lib/build/recipe/dashboard/api/userdetails/userPasswordPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const emailpassword_1 = __importDefault(require("../../../emailpassword"));
const recipe_2 = __importDefault(require("../../../thirdpartyemailpassword/recipe"));
const thirdpartyemailpassword_1 = __importDefault(require("../../../thirdpartyemailpassword"));
const constants_1 = require("../../../emailpassword/constants");
const userPasswordPut = (_, options, userContext) =>
const userPasswordPut = (_, tenantId, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const userId = requestBody.userId;
Expand Down Expand Up @@ -86,14 +86,19 @@ const userPasswordPut = (_, options, userContext) =>
error: passwordValidationError,
};
}
const passwordResetToken = yield emailpassword_1.default.createResetPasswordToken(userId, userContext);
const passwordResetToken = yield emailpassword_1.default.createResetPasswordToken(
userId,
tenantId,
userContext
);
if (passwordResetToken.status === "UNKNOWN_USER_ID_ERROR") {
// Techincally it can but its an edge case so we assume that it wont
throw new Error("Should never come here");
}
const passwordResetResponse = yield emailpassword_1.default.resetPasswordUsingToken(
passwordResetToken.token,
newPassword,
tenantId,
userContext
);
if (passwordResetResponse.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR") {
Expand All @@ -115,6 +120,7 @@ const userPasswordPut = (_, options, userContext) =>
}
const passwordResetToken = yield thirdpartyemailpassword_1.default.createResetPasswordToken(
userId,
tenantId,
userContext
);
if (passwordResetToken.status === "UNKNOWN_USER_ID_ERROR") {
Expand All @@ -124,6 +130,7 @@ const userPasswordPut = (_, options, userContext) =>
const passwordResetResponse = yield thirdpartyemailpassword_1.default.resetPasswordUsingToken(
passwordResetToken.token,
newPassword,
tenantId,
userContext
);
if (passwordResetResponse.status === "RESET_PASSWORD_INVALID_TOKEN_ERROR") {
Expand Down
7 changes: 6 additions & 1 deletion lib/build/recipe/dashboard/api/userdetails/userPut.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ declare type Response =
status: "INVALID_PHONE_ERROR";
error: string;
};
export declare const userPut: (_: APIInterface, options: APIOptions, userContext: any) => Promise<Response>;
export declare const userPut: (
_: APIInterface,
___: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
export {};
2 changes: 1 addition & 1 deletion lib/build/recipe/dashboard/api/userdetails/userPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const updatePhoneForRecipeId = (recipeId, userId, phone, userContext) =>
*/
throw new Error("Should never come here");
});
const userPut = (_, options, userContext) =>
const userPut = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const userId = requestBody.userId;
Expand Down
4 changes: 2 additions & 2 deletions lib/build/recipe/dashboard/api/userdetails/userSessionsGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.userSessionsGet = void 0;
const error_1 = __importDefault(require("../../../../error"));
const session_1 = __importDefault(require("../../../session"));
const userSessionsGet = (_, options, userContext) =>
const userSessionsGet = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const userId = options.req.getKeyValueFromQuery("userId");
if (userId === undefined) {
Expand All @@ -48,7 +48,7 @@ const userSessionsGet = (_, options, userContext) =>
type: error_1.default.BAD_INPUT_ERROR,
});
}
const response = yield session_1.default.getAllSessionHandlesForUser(userId, userContext);
const response = yield session_1.default.getAllSessionHandlesForUser(userId, undefined, userContext);
let sessions = [];
let sessionInfoPromises = [];
for (let i = 0; i < response.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ import { APIInterface, APIOptions } from "../../types";
declare type Response = {
status: "OK";
};
export declare const userSessionsPost: (_: APIInterface, options: APIOptions, userContext: any) => Promise<Response>;
export declare const userSessionsPost: (
_: APIInterface,
___: string,
options: APIOptions,
userContext: any
) => Promise<Response>;
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.userSessionsPost = void 0;
const error_1 = __importDefault(require("../../../../error"));
const session_1 = __importDefault(require("../../../session"));
const userSessionsPost = (_, options, userContext) =>
const userSessionsPost = (_, ___, options, userContext) =>
__awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield options.req.getJSONBody();
const sessionHandles = requestBody.sessionHandles;
Expand Down
Loading

0 comments on commit 4564d9d

Please sign in to comment.