supertokens / docs

SuperTokens documentation
39 stars 66 forks source link

Golang emailpassword change password #704

Closed trivialkettle closed 10 months ago

trivialkettle commented 10 months ago

Hi, I spotted an error at the golang code for changePasswordAPI: https://supertokens.com/docs/emailpassword/common-customizations/change-password

    // call signin to check that the input is correct
    isPasswordValid, err := emailpassword.SignIn(sessionContainer.GetTenantId(), userInfo.Email, requestBody.OldPassword)
    if err != nil {
        // TODO: Handle error
        return
    }

    if isPasswordValid.OK != nil {
        // TODO: Handle error
        return
    }

This should be

    // call signin to check that the input is correct
    isPasswordValid, err := emailpassword.SignIn(sessionContainer.GetTenantId(), userInfo.Email, requestBody.OldPassword)
    if err != nil {
        // TODO: Handle error
        return
    }

    if isPasswordValid.WrongCredentialsError != nil {
        // TODO: Handle error
        return
    }

Note the if isPasswordValid.WrongCredentialsError != nil { check

rishabhpoddar commented 10 months ago

Thanks for this! We will fix this in the next docs update (will be out in a few days).

trivialkettle commented 10 months ago

Hi, I checked you commit that references this issue and did not see a fix for this issue, though you fixed my other issue #705 .

rishabhpoddar commented 10 months ago

Oh yea, i was fixing both together along with some other stuff, and messed up the commit links. This is fixed: https://github.com/supertokens/docs/commit/ed1279865bd8fb9a114cf829277bd12039e9b026