Generating backup codes gives error

Doing:
const { data, error } = await authClient.twoFactor.generateBackupCodes({
password: values.currentPassword,
});
const { data, error } = await authClient.twoFactor.generateBackupCodes({
password: values.currentPassword,
});
and getting:
⨯ [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
⨯ [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
3 Replies
bekacru
bekacru6d ago
This error is related to prisma. Most likely missing schema.
ted
tedOP6d ago
thanks i’ll check my schema now i did some debugging and i believe that the userId field needs to be unique, prisma telling me that it can only do an updateOne when id is specified, instead of userId - so i fixed it by manually adding @unique to the userId field, maybe this is a bug for prisma adaptor
ted
tedOP6d ago
GitHub
fix: userId should be unique on 2fa plugin by t3duk · Pull Request ...
When using the Prisma DB adaptor (haven't tested others) when trying to generate new backup codes (when 2fa is enabled) it fails. This is because when running update (instead of updateMany)...

Did you find this page helpful?