resetByExistingPassword

abstract suspend fun resetByExistingPassword(request: IPasswordsExistingPasswordResetParameters): PasswordsExistingPasswordResetResponse

Resets a user's password by verifying their existing password, then setting a new one. Calls the POST /sdk/v1/passwords/existing_password/reset endpoint.

Kotlin:

StytchConsumer.passwords.resetByExistingPassword(
PasswordsExistingPasswordResetParameters(
email = "user@example.com",
existingPassword = "oldpassword",
newPassword = "newpassword",
)
)

iOS:

let params = PasswordsExistingPasswordResetParameters(
email: "user@example.com",
existingPassword: "oldpassword",
newPassword: "newpassword"
)
let response = try await StytchConsumer.passwords.resetByExistingPassword(params)

React Native:

StytchConsumer.passwords.resetByExistingPassword({
email: "user@example.com",
existingPassword: "oldpassword",
newPassword: "newpassword",
})

Return

PasswordsExistingPasswordResetResponse containing the authenticated session and user.

Parameters

request
  • IPasswordsExistingPasswordResetParameters

  • email — The user's email address.

  • existingPassword — The user's current password for verification.

  • newPassword — The new password to set.

  • sessionDurationMinutes? — Duration of the session to create, in minutes.

Throws

StytchError

if the existing password is incorrect or the new password is too weak.

if the coroutine is cancelled.