Skip to content

Commit d070226

Browse files
porcellusMihaly LengyelRishabh
authored
Reset password resp (#242)
* Adding userId to the reset password consume API response * Fixed core version reference * Updated changelog * Reverted accidental update * Updated changelog and version references * sends optional user ID from API recipe function as well * adds 2.12 CDI version support and adds test * small bug fix in types Co-authored-by: Mihaly Lengyel <[email protected]> Co-authored-by: Rishabh <[email protected]>
1 parent 6283b68 commit d070226

File tree

15 files changed

+169
-35
lines changed

15 files changed

+169
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
### Changed
12+
13+
- Added userId as an optional property to the response of `recipe/user/password/reset`.
1114
- Fixes https://github.com/supertokens/supertokens-node/issues/244 - throws an error if a user tries to update email / password of a third party login user.
1215
- add workflow to verify if pr title follows conventional commits
1316

coreDriverInterfaceSupported.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"_comment": "contains a list of core-driver interfaces branch names that this core supports",
3-
"versions": ["2.8", "2.9", "2.10", "2.11"]
3+
"versions": ["2.8", "2.9", "2.10", "2.11", "2.12"]
44
}

lib/build/recipe/emailpassword/api/passwordReset.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ function passwordReset(apiImplementation, options) {
7373
});
7474
}
7575
let result = yield apiImplementation.passwordResetPOST({ formFields, token, options });
76-
utils_1.send200Response(options.res, result);
76+
utils_1.send200Response(
77+
options.res,
78+
result.status === "OK"
79+
? {
80+
status: "OK",
81+
}
82+
: result
83+
);
7784
return true;
7885
});
7986
}

lib/build/recipe/emailpassword/index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ export default class Wrapper {
4545
static resetPasswordUsingToken(
4646
token: string,
4747
newPassword: string
48-
): Promise<{
49-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
50-
}>;
48+
): Promise<
49+
| {
50+
status: "OK";
51+
userId?: string | undefined;
52+
}
53+
| {
54+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
55+
}
56+
>;
5157
static updateEmailOrPassword(input: {
5258
userId: string;
5359
email?: string;

lib/build/recipe/emailpassword/types.d.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,19 @@ export declare type RecipeInterface = {
204204
resetPasswordUsingToken(input: {
205205
token: string;
206206
newPassword: string;
207-
}): Promise<{
208-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
209-
}>;
207+
}): Promise<
208+
| {
209+
status: "OK";
210+
/**
211+
* The id of the user whose password was reset.
212+
* Defined for Core versions 3.9 or later
213+
*/
214+
userId?: string;
215+
}
216+
| {
217+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
218+
}
219+
>;
210220
updateEmailOrPassword(input: {
211221
userId: string;
212222
email?: string;
@@ -254,9 +264,15 @@ export declare type APIInterface = {
254264
}[];
255265
token: string;
256266
options: APIOptions;
257-
}) => Promise<{
258-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
259-
}>);
267+
}) => Promise<
268+
| {
269+
status: "OK";
270+
userId?: string;
271+
}
272+
| {
273+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
274+
}
275+
>);
260276
signInPOST:
261277
| undefined
262278
| ((input: {

lib/build/recipe/thirdpartyemailpassword/index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ export default class Wrapper {
6565
static resetPasswordUsingToken(
6666
token: string,
6767
newPassword: string
68-
): Promise<{
69-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
70-
}>;
68+
): Promise<
69+
| {
70+
status: "OK";
71+
userId?: string | undefined;
72+
}
73+
| {
74+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
75+
}
76+
>;
7177
static updateEmailOrPassword(input: {
7278
userId: string;
7379
email?: string;

lib/build/recipe/thirdpartyemailpassword/types.d.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,19 @@ export declare type RecipeInterface = {
206206
resetPasswordUsingToken(input: {
207207
token: string;
208208
newPassword: string;
209-
}): Promise<{
210-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
211-
}>;
209+
}): Promise<
210+
| {
211+
status: "OK";
212+
/**
213+
* The id of the user whose password was reset.
214+
* Defined for Core versions 3.9 or later
215+
*/
216+
userId?: string;
217+
}
218+
| {
219+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
220+
}
221+
>;
212222
updateEmailOrPassword(input: {
213223
userId: string;
214224
email?: string;
@@ -258,9 +268,15 @@ export declare type APIInterface = {
258268
}[];
259269
token: string;
260270
options: EmailPasswordAPIOptions;
261-
}) => Promise<{
262-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
263-
}>);
271+
}) => Promise<
272+
| {
273+
status: "OK";
274+
userId?: string;
275+
}
276+
| {
277+
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
278+
}
279+
>);
264280
thirdPartySignInUpPOST:
265281
| undefined
266282
| ((input: {

lib/build/version.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/emailpassword/api/implementation.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,17 @@ export default function getAPIImplementation(): APIInterface {
8484
}[];
8585
token: string;
8686
options: APIOptions;
87-
}): Promise<{
88-
status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
89-
}> {
87+
}): Promise<
88+
| {
89+
status: "OK";
90+
/**
91+
* The id of the user whose password was reset.
92+
* Defined for Core versions 3.9 or later
93+
*/
94+
userId?: string;
95+
}
96+
| { status: "RESET_PASSWORD_INVALID_TOKEN_ERROR" }
97+
> {
9098
let newPassword = formFields.filter((f) => f.id === "password")[0].value;
9199

92100
let response = await options.recipeImplementation.resetPasswordUsingToken({ token, newPassword });

lib/ts/recipe/emailpassword/api/passwordReset.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export default async function passwordReset(apiImplementation: APIInterface, opt
5050

5151
let result = await apiImplementation.passwordResetPOST({ formFields, token, options });
5252

53-
send200Response(options.res, result);
53+
send200Response(
54+
options.res,
55+
result.status === "OK"
56+
? {
57+
status: "OK",
58+
}
59+
: result
60+
);
5461
return true;
5562
}

0 commit comments

Comments
 (0)