Skip to content

Commit 96f2027

Browse files
committed
Add password recovery functions
1 parent bb5eff0 commit 96f2027

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

packages/client/src/AccountsClient.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,38 @@ export class AccountsClient {
226226
throw new AccountsError(err.message);
227227
}
228228
}
229+
230+
async verifyEmail(token: string): Promise<void> {
231+
try {
232+
await this.transport.verifyEmail(token);
233+
} catch (err) {
234+
throw new AccountsError(err.message);
235+
}
236+
}
237+
238+
async resetPassword(token: string, newPassword: string): Promise<void> {
239+
try {
240+
await this.transport.resetPassword(token, newPassword);
241+
} catch (err) {
242+
throw new AccountsError(err.message);
243+
}
244+
}
245+
246+
async requestPasswordReset(userId: string, email?: string): Promise<void> {
247+
try {
248+
await this.transport.sendResetPasswordEmail(userId, email);
249+
} catch (err) {
250+
throw new AccountsError(err.message);
251+
}
252+
}
253+
254+
async requestVerificationEmail(userId: string, email?: string): Promise<void> {
255+
try {
256+
await this.transport.sendVerificationEmail(userId, email);
257+
} catch (err) {
258+
throw new AccountsError(err.message);
259+
}
260+
}
229261
}
230262

231263
const Accounts = {
@@ -269,6 +301,18 @@ const Accounts = {
269301
refreshSession(): Promise<void> {
270302
return this.instance.refreshSession();
271303
},
304+
verifyEmail(token: string): Promise<void> {
305+
return this.instance.verifyEmail(token);
306+
},
307+
resetPassword(token: string, newPassword: string): Promise<void> {
308+
return this.instance.resetPassword(token, newPassword);
309+
},
310+
requestPasswordReset(userId: string, email?: string): Promise<void> {
311+
return this.instance.requestPasswordReset(userId, email);
312+
},
313+
requestVerificationEmail(userId: string, email?: string): Promise<void> {
314+
return this.instance.requestVerificationEmail(userId, email);
315+
},
272316
};
273317

274318
export default Accounts;

0 commit comments

Comments
 (0)