Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe interface changes regarding account-linking #439

Merged
merged 15 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ declare type Response =
| {
status: "OK";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
| {
status: "INVALID_PASSWORD_ERROR";
error: string;
Expand Down
6 changes: 6 additions & 0 deletions lib/build/recipe/dashboard/api/userdetails/userPasswordPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ exports.userPasswordPut = (_, options) =>
// Techincally it can but its an edge case so we assume that it wont
throw new Error("Should never come here");
}
if (passwordResetToken.status === "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR") {
return passwordResetToken;
}
const passwordResetResponse = yield emailpassword_1.default.resetPasswordUsingToken(
passwordResetToken.token,
newPassword
Expand All @@ -111,6 +114,9 @@ exports.userPasswordPut = (_, options) =>
// Techincally it can but its an edge case so we assume that it wont
throw new Error("Should never come here");
}
if (passwordResetToken.status === "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR") {
return passwordResetToken;
}
const passwordResetResponse = yield thirdpartyemailpassword_1.default.resetPasswordUsingToken(
passwordResetToken.token,
newPassword
Expand Down
13 changes: 13 additions & 0 deletions lib/build/recipe/emailpassword/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ const logger_1 = require("../../../logger");
const session_1 = require("../../session");
function getAPIImplementation() {
return {
postSignInAccountLinkingPOST: function (_input) {
return __awaiter(this, void 0, void 0, function* () {
return {
status: "ACCOUNT_LINK_FAILURE",
reason: "",
contactSupport: false,
recipeUserCreated: false,
};
});
},
emailExistsGET: function ({ email, options, userContext }) {
return __awaiter(this, void 0, void 0, function* () {
let user = yield options.recipeImplementation.getUserByEmail({ email, userContext });
Expand Down Expand Up @@ -63,6 +73,9 @@ function getAPIImplementation() {
status: "OK",
};
}
if (response.status === "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR") {
return response;
}
let passwordResetLink =
options.appInfo.websiteDomain.getAsStringDangerous() +
options.appInfo.websiteBasePath.getAsStringDangerous() +
Expand Down
11 changes: 9 additions & 2 deletions lib/build/recipe/emailpassword/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default class Wrapper {
| {
status: "UNKNOWN_USER_ID_ERROR";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
>;
static resetPasswordUsingToken(
token: string,
Expand All @@ -52,7 +55,7 @@ export default class Wrapper {
): Promise<
| {
status: "OK";
userId?: string | undefined;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand All @@ -64,7 +67,11 @@ export default class Wrapper {
password?: string;
userContext?: any;
}): Promise<{
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
status:
| "OK"
| "EMAIL_ALREADY_EXISTS_ERROR"
| "UNKNOWN_USER_ID_ERROR"
| "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}>;
static sendEmail(
input: TypeEmailPasswordEmailDeliveryInput & {
Expand Down
51 changes: 44 additions & 7 deletions lib/build/recipe/emailpassword/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export declare type RecipeInterface = {
| {
status: "UNKNOWN_USER_ID_ERROR";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
>;
resetPasswordUsingToken(input: {
token: string;
Expand All @@ -123,11 +126,7 @@ export declare type RecipeInterface = {
}): Promise<
| {
status: "OK";
/**
* The id of the user whose password was reset.
* Defined for Core versions 3.9 or later
*/
userId?: string;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand All @@ -139,7 +138,11 @@ export declare type RecipeInterface = {
password?: string;
userContext: any;
}): Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "EMAIL_ALREADY_EXISTS_ERROR";
status:
| "OK"
| "UNKNOWN_USER_ID_ERROR"
| "EMAIL_ALREADY_EXISTS_ERROR"
| "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}>;
};
export declare type APIOptions = {
Expand Down Expand Up @@ -179,6 +182,12 @@ export declare type APIInterface = {
| {
status: "OK";
}
| {
status: "PASSWORD_RESET_NOT_ALLOWED_CONTACT_SUPPORT";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
| GeneralErrorResponse
>);
passwordResetPOST:
Expand All @@ -194,7 +203,7 @@ export declare type APIInterface = {
}) => Promise<
| {
status: "OK";
userId?: string;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand Down Expand Up @@ -239,13 +248,41 @@ export declare type APIInterface = {
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
status: "SIGNUP_NOT_ALLOWED";
}
| GeneralErrorResponse
>);
postSignInAccountLinkingPOST:
| undefined
| ((input: {
formFields: {
id: string;
value: string;
}[];
session: SessionContainerInterface;
options: APIOptions;
userContext: any;
}) => Promise<
| {
status: "OK";
user: User;
session: SessionContainerInterface;
}
| {
status: "ACCOUNT_LINK_FAILURE";
reason: string;
contactSupport: boolean;
recipeUserCreated: boolean;
}
| GeneralErrorResponse
>);
};
export declare type TypeEmailPasswordPasswordResetEmailDeliveryInput = {
type: "PASSWORD_RESET";
user: {
id: string;
recipeUserId: string;
email: string;
};
passwordResetLink: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getIterfaceImpl(apiImplmentation) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
return {
emailExistsGET:
(_a = apiImplmentation.emailPasswordEmailExistsGET) === null || _a === void 0
Expand All @@ -21,6 +21,10 @@ function getIterfaceImpl(apiImplmentation) {
(_e = apiImplmentation.emailPasswordSignUpPOST) === null || _e === void 0
? void 0
: _e.bind(apiImplmentation),
postSignInAccountLinkingPOST:
(_f = apiImplmentation.emailPasswordPostSignInAccountLinkingPOST) === null || _f === void 0
? void 0
: _f.bind(apiImplmentation),
};
}
exports.default = getIterfaceImpl;
18 changes: 11 additions & 7 deletions lib/build/recipe/thirdpartyemailpassword/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const implementation_2 = require("../../thirdparty/api/implementation");
const emailPasswordAPIImplementation_1 = require("./emailPasswordAPIImplementation");
const thirdPartyAPIImplementation_1 = require("./thirdPartyAPIImplementation");
function getAPIImplementation() {
var _a, _b, _c, _d, _e, _f, _g, _h;
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
let emailPasswordImplementation = implementation_1.default();
let thirdPartyImplementation = implementation_2.default();
return {
Expand All @@ -29,18 +29,22 @@ function getAPIImplementation() {
(_e = emailPasswordImplementation.generatePasswordResetTokenPOST) === null || _e === void 0
? void 0
: _e.bind(emailPasswordAPIImplementation_1.default(this)),
passwordResetPOST:
(_f = emailPasswordImplementation.passwordResetPOST) === null || _f === void 0
emailPasswordPostSignInAccountLinkingPOST:
(_f = emailPasswordImplementation.postSignInAccountLinkingPOST) === null || _f === void 0
? void 0
: _f.bind(emailPasswordAPIImplementation_1.default(this)),
passwordResetPOST:
(_g = emailPasswordImplementation.passwordResetPOST) === null || _g === void 0
? void 0
: _g.bind(emailPasswordAPIImplementation_1.default(this)),
thirdPartySignInUpPOST:
(_g = thirdPartyImplementation.signInUpPOST) === null || _g === void 0
(_h = thirdPartyImplementation.signInUpPOST) === null || _h === void 0
? void 0
: _g.bind(thirdPartyAPIImplementation_1.default(this)),
: _h.bind(thirdPartyAPIImplementation_1.default(this)),
appleRedirectHandlerPOST:
(_h = thirdPartyImplementation.appleRedirectHandlerPOST) === null || _h === void 0
(_j = thirdPartyImplementation.appleRedirectHandlerPOST) === null || _j === void 0
? void 0
: _h.bind(thirdPartyAPIImplementation_1.default(this)),
: _j.bind(thirdPartyAPIImplementation_1.default(this)),
};
}
exports.default = getAPIImplementation;
11 changes: 9 additions & 2 deletions lib/build/recipe/thirdpartyemailpassword/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default class Wrapper {
| {
status: "UNKNOWN_USER_ID_ERROR";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
>;
static resetPasswordUsingToken(
token: string,
Expand All @@ -69,7 +72,7 @@ export default class Wrapper {
): Promise<
| {
status: "OK";
userId?: string | undefined;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand All @@ -81,7 +84,11 @@ export default class Wrapper {
password?: string;
userContext?: any;
}): Promise<{
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
status:
| "OK"
| "EMAIL_ALREADY_EXISTS_ERROR"
| "UNKNOWN_USER_ID_ERROR"
| "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}>;
static Google: typeof import("../thirdparty/providers/google").default;
static Github: typeof import("../thirdparty/providers/github").default;
Expand Down
50 changes: 43 additions & 7 deletions lib/build/recipe/thirdpartyemailpassword/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export declare type RecipeInterface = {
| {
status: "UNKNOWN_USER_ID_ERROR";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
>;
resetPasswordUsingToken(input: {
token: string;
Expand All @@ -135,11 +138,7 @@ export declare type RecipeInterface = {
}): Promise<
| {
status: "OK";
/**
* The id of the user whose password was reset.
* Defined for Core versions 3.9 or later
*/
userId?: string;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand All @@ -151,7 +150,11 @@ export declare type RecipeInterface = {
password?: string;
userContext: any;
}): Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "EMAIL_ALREADY_EXISTS_ERROR";
status:
| "OK"
| "UNKNOWN_USER_ID_ERROR"
| "EMAIL_ALREADY_EXISTS_ERROR"
| "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}>;
};
export declare type EmailPasswordAPIOptions = EmailPasswordAPIOptionsOriginal;
Expand Down Expand Up @@ -196,6 +199,12 @@ export declare type APIInterface = {
| {
status: "OK";
}
| {
status: "PASSWORD_RESET_NOT_ALLOWED_CONTACT_SUPPORT";
}
| {
status: "PROVIDE_RECIPE_USER_ID_AS_USER_ID_ERROR";
}
| GeneralErrorResponse
>);
passwordResetPOST:
Expand All @@ -211,7 +220,7 @@ export declare type APIInterface = {
}) => Promise<
| {
status: "OK";
userId?: string;
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
Expand Down Expand Up @@ -241,6 +250,30 @@ export declare type APIInterface = {
status: "NO_EMAIL_GIVEN_BY_PROVIDER";
}
>);
emailPasswordPostSignInAccountLinkingPOST:
| undefined
| ((input: {
formFields: {
id: string;
value: string;
}[];
session: SessionContainerInterface;
options: EmailPasswordAPIOptions;
userContext: any;
}) => Promise<
| {
status: "OK";
user: User;
session: SessionContainerInterface;
}
| {
status: "ACCOUNT_LINK_FAILURE";
reason: string;
contactSupport: boolean;
recipeUserCreated: boolean;
}
| GeneralErrorResponse
>);
emailPasswordSignInPOST:
| undefined
| ((input: {
Expand Down Expand Up @@ -279,6 +312,9 @@ export declare type APIInterface = {
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
status: "SIGNUP_NOT_ALLOWED";
}
| GeneralErrorResponse
>);
appleRedirectHandlerPOST:
Expand Down
Loading