mirror of
https://github.com/better-auth/better-auth.git
synced 2026-06-02 12:26:43 -05:00
test: add validation for password update with incorrect current password
This commit is contained in:
@@ -162,6 +162,31 @@ describe("updateUser", async () => {
|
||||
expect(signInCurrentPassword.data).toBeNull();
|
||||
});
|
||||
|
||||
it("should not update password if current password is wrong", async () => {
|
||||
const newHeaders = new Headers();
|
||||
await client.signUp.email({
|
||||
name: "name",
|
||||
email: "new-email-2@email.com",
|
||||
password: "password",
|
||||
fetchOptions: {
|
||||
onSuccess: sessionSetter(newHeaders),
|
||||
},
|
||||
});
|
||||
const res = await client.changePassword({
|
||||
newPassword: "newPassword",
|
||||
currentPassword: "wrongPassword",
|
||||
fetchOptions: {
|
||||
headers: newHeaders,
|
||||
},
|
||||
});
|
||||
expect(res.data).toBeNull();
|
||||
const signInAttempt = await client.signIn.email({
|
||||
email: "new-email-2@email.com",
|
||||
password: "newPassword",
|
||||
});
|
||||
expect(signInAttempt.data).toBeNull();
|
||||
});
|
||||
|
||||
it("should revoke other sessions", async () => {
|
||||
const newHeaders = new Headers();
|
||||
await client.changePassword({
|
||||
|
||||
Reference in New Issue
Block a user