Skip to content

Commit

Permalink
fix: tenantid compulsory (#633)
Browse files Browse the repository at this point in the history
* fix: tenantid compulsory

* fix: type fix

* fix: type fix
  • Loading branch information
sattvikc authored Jul 12, 2023
1 parent c3ca729 commit e0ab26e
Show file tree
Hide file tree
Showing 64 changed files with 428 additions and 536 deletions.
8 changes: 5 additions & 3 deletions lib/build/index.d.ts

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

4 changes: 2 additions & 2 deletions lib/build/index.js

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

Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const userEmailVerifyPut = (_, tenantId, options, userContext) =>
}
if (verified) {
const tokenResponse = yield emailverification_1.default.createEmailVerificationToken(
tenantId,
userId,
undefined,
tenantId,
userContext
);
if (tokenResponse.status === "EMAIL_ALREADY_VERIFIED_ERROR") {
Expand All @@ -69,8 +69,8 @@ const userEmailVerifyPut = (_, tenantId, options, userContext) =>
};
}
const verifyResponse = yield emailverification_1.default.verifyEmailUsingToken(
tokenResponse.token,
tenantId,
tokenResponse.token,
userContext
);
if (verifyResponse.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ const userEmailVerifyTokenPost = (_, tenantId, options, userContext) =>
type: error_1.default.BAD_INPUT_ERROR,
});
}
return yield emailverification_1.default.sendEmailVerificationEmail(userId, undefined, tenantId, userContext);
return yield emailverification_1.default.sendEmailVerificationEmail(tenantId, userId, undefined, userContext);
});
exports.userEmailVerifyTokenPost = userEmailVerifyTokenPost;
4 changes: 2 additions & 2 deletions lib/build/recipe/emailpassword/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ function getAPIImplementation() {
let session = yield session_1.default.createNewSession(
options.req,
options.res,
tenantId,
user.id,
{},
{},
tenantId,
userContext
);
return {
Expand All @@ -138,10 +138,10 @@ function getAPIImplementation() {
let session = yield session_1.default.createNewSession(
options.req,
options.res,
tenantId,
user.id,
{},
{},
tenantId,
userContext
);
return {
Expand Down
14 changes: 7 additions & 7 deletions lib/build/recipe/emailpassword/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export default class Wrapper {
static init: typeof Recipe.init;
static Error: typeof SuperTokensError;
static signUp(
tenantId: string,
email: string,
password: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -20,9 +20,9 @@ export default class Wrapper {
}
>;
static signIn(
tenantId: string,
email: string,
password: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -34,10 +34,10 @@ export default class Wrapper {
}
>;
static getUserById(userId: string, userContext?: any): Promise<User | undefined>;
static getUserByEmail(email: string, tenantId?: string, userContext?: any): Promise<User | undefined>;
static getUserByEmail(tenantId: string, email: string, userContext?: any): Promise<User | undefined>;
static createResetPasswordToken(
tenantId: string,
userId: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -49,9 +49,9 @@ export default class Wrapper {
}
>;
static resetPasswordUsingToken(
tenantId: string,
token: string,
newPassword: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand Down Expand Up @@ -79,8 +79,8 @@ export default class Wrapper {
}
>;
static createResetPasswordLink(
tenantId: string,
userId: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -92,8 +92,8 @@ export default class Wrapper {
}
>;
static sendResetPasswordEmail(
tenantId: string,
userId: string,
tenantId?: string,
userContext?: any
): Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
Expand Down
18 changes: 9 additions & 9 deletions lib/build/recipe/emailpassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ const error_1 = __importDefault(require("./error"));
const constants_1 = require("../multitenancy/constants");
const utils_1 = require("./utils");
class Wrapper {
static signUp(email, password, tenantId, userContext) {
static signUp(tenantId, email, password, userContext) {
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.signUp({
email,
password,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
userContext: userContext === undefined ? {} : userContext,
});
}
static signIn(email, password, tenantId, userContext) {
static signIn(tenantId, email, password, userContext) {
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.signIn({
email,
password,
Expand All @@ -78,21 +78,21 @@ class Wrapper {
userContext: userContext === undefined ? {} : userContext,
});
}
static getUserByEmail(email, tenantId, userContext) {
static getUserByEmail(tenantId, email, userContext) {
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.getUserByEmail({
email,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
userContext: userContext === undefined ? {} : userContext,
});
}
static createResetPasswordToken(userId, tenantId, userContext) {
static createResetPasswordToken(tenantId, userId, userContext) {
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.createResetPasswordToken({
userId,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
userContext: userContext === undefined ? {} : userContext,
});
}
static resetPasswordUsingToken(token, newPassword, tenantId, userContext) {
static resetPasswordUsingToken(tenantId, token, newPassword, userContext) {
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.resetPasswordUsingToken({
token,
newPassword,
Expand All @@ -110,9 +110,9 @@ class Wrapper {
})
);
}
static createResetPasswordLink(userId, tenantId, userContext) {
static createResetPasswordLink(tenantId, userId, userContext) {
return __awaiter(this, void 0, void 0, function* () {
let token = yield exports.createResetPasswordToken(userId, tenantId, userContext);
let token = yield exports.createResetPasswordToken(tenantId, userId, userContext);
if (token.status === "UNKNOWN_USER_ID_ERROR") {
return token;
}
Expand All @@ -128,9 +128,9 @@ class Wrapper {
};
});
}
static sendResetPasswordEmail(userId, tenantId, userContext) {
static sendResetPasswordEmail(tenantId, userId, userContext) {
return __awaiter(this, void 0, void 0, function* () {
let link = yield exports.createResetPasswordLink(userId, tenantId, userContext);
let link = yield exports.createResetPasswordLink(tenantId, userId, userContext);
if (link.status === "UNKNOWN_USER_ID_ERROR") {
return link;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/emailpassword/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,6 @@ export declare type TypeEmailPasswordPasswordResetEmailDeliveryInput = {
email: string;
};
passwordResetLink: string;
tenantId?: string;
tenantId: string;
};
export declare type TypeEmailPasswordEmailDeliveryInput = TypeEmailPasswordPasswordResetEmailDeliveryInput;
10 changes: 5 additions & 5 deletions lib/build/recipe/emailverification/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default class Wrapper {
static Error: typeof SuperTokensError;
static EmailVerificationClaim: import("./emailVerificationClaim").EmailVerificationClaimClass;
static createEmailVerificationToken(
tenantId: string,
userId: string,
email?: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -21,9 +21,9 @@ export default class Wrapper {
}
>;
static createEmailVerificationLink(
tenantId: string,
userId: string,
email?: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -35,9 +35,9 @@ export default class Wrapper {
}
>;
static sendEmailVerificationEmail(
tenantId: string,
userId: string,
email?: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -48,8 +48,8 @@ export default class Wrapper {
}
>;
static verifyEmailUsingToken(
tenantId: string,
token: string,
tenantId?: string,
userContext?: any
): Promise<
| {
Expand All @@ -62,9 +62,9 @@ export default class Wrapper {
>;
static isEmailVerified(userId: string, email?: string, userContext?: any): Promise<boolean>;
static revokeEmailVerificationTokens(
tenantId: string,
userId: string,
email?: string,
tenantId?: string,
userContext?: any
): Promise<{
status: string;
Expand Down
27 changes: 12 additions & 15 deletions lib/build/recipe/emailverification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ exports.EmailVerificationClaim = exports.sendEmail = exports.unverifyEmail = exp
const recipe_1 = __importDefault(require("./recipe"));
const error_1 = __importDefault(require("./error"));
const emailVerificationClaim_1 = require("./emailVerificationClaim");
const constants_1 = require("../multitenancy/constants");
const utils_1 = require("./utils");
class Wrapper {
static createEmailVerificationToken(userId, email, tenantId, userContext) {
static createEmailVerificationToken(tenantId, userId, email, userContext) {
return __awaiter(this, void 0, void 0, function* () {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
if (email === undefined) {
Expand All @@ -75,19 +74,19 @@ class Wrapper {
return yield recipeInstance.recipeInterfaceImpl.createEmailVerificationToken({
userId,
email: email,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
tenantId,
userContext: userContext === undefined ? {} : userContext,
});
});
}
static createEmailVerificationLink(userId, email, tenantId, userContext) {
static createEmailVerificationLink(tenantId, userId, email, userContext) {
return __awaiter(this, void 0, void 0, function* () {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
const appInfo = recipeInstance.getAppInfo();
let emailVerificationToken = yield exports.createEmailVerificationToken(
tenantId,
userId,
email,
tenantId,
userContext
);
if (emailVerificationToken.status === "EMAIL_ALREADY_VERIFIED_ERROR") {
Expand All @@ -101,12 +100,12 @@ class Wrapper {
appInfo,
token: emailVerificationToken.token,
recipeId: recipeInstance.getRecipeId(),
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
tenantId,
}),
};
});
}
static sendEmailVerificationEmail(userId, email, tenantId, userContext) {
static sendEmailVerificationEmail(tenantId, userId, email, userContext) {
return __awaiter(this, void 0, void 0, function* () {
if (email === undefined) {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
Expand All @@ -121,7 +120,7 @@ class Wrapper {
throw new global.Error("Unknown User ID provided without email");
}
}
let emailVerificationLink = yield this.createEmailVerificationLink(userId, email, tenantId, userContext);
let emailVerificationLink = yield this.createEmailVerificationLink(tenantId, userId, email, userContext);
if (emailVerificationLink.status === "EMAIL_ALREADY_VERIFIED_ERROR") {
return {
status: "EMAIL_ALREADY_VERIFIED_ERROR",
Expand All @@ -141,11 +140,11 @@ class Wrapper {
};
});
}
static verifyEmailUsingToken(token, tenantId, userContext) {
static verifyEmailUsingToken(tenantId, token, userContext) {
return __awaiter(this, void 0, void 0, function* () {
return yield recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.verifyEmailUsingToken({
token,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
tenantId,
userContext: userContext === undefined ? {} : userContext,
});
});
Expand All @@ -170,7 +169,7 @@ class Wrapper {
});
});
}
static revokeEmailVerificationTokens(userId, email, tenantId, userContext) {
static revokeEmailVerificationTokens(tenantId, userId, email, userContext) {
return __awaiter(this, void 0, void 0, function* () {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
// If the dev wants to delete the tokens for an old email address of the user they can pass the address
Expand All @@ -194,7 +193,7 @@ class Wrapper {
return yield recipeInstance.recipeInterfaceImpl.revokeEmailVerificationTokens({
userId,
email: email,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
tenantId,
userContext: userContext === undefined ? {} : userContext,
});
});
Expand Down Expand Up @@ -226,9 +225,7 @@ class Wrapper {
return __awaiter(this, void 0, void 0, function* () {
let recipeInstance = recipe_1.default.getInstanceOrThrowError();
return yield recipeInstance.emailDelivery.ingredientInterfaceImpl.sendEmail(
Object.assign(Object.assign({ userContext: {} }, input), {
tenantId: input.tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : input.tenantId,
})
Object.assign(Object.assign({ userContext: {} }, input), { tenantId: input.tenantId })
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/emailverification/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export declare type TypeEmailVerificationEmailDeliveryInput = {
email: string;
};
emailVerifyLink: string;
tenantId?: string;
tenantId: string;
};
export declare type GetEmailForUserIdFunc = (
userId: string,
Expand Down
1 change: 1 addition & 0 deletions lib/build/recipe/multitenancy/api/loginMethods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { APIInterface, APIOptions } from "../";
export default function loginMethodsAPI(
apiImplementation: APIInterface,
tenantId: string,
options: APIOptions,
userContext: any
): Promise<boolean>;
Loading

0 comments on commit e0ab26e

Please sign in to comment.