wvn
wvn
Explore posts from servers
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
# SERVER_ERROR: [Error [PrismaClientValidationError]:
Invalid `db[getModelName(model)].update()` invocation in
C:\Users\Admin\Desktop\LicensingWeb\my-app\.next\server\chunks\node_modules_better-auth_dist_e7fe42cb._.js:3190:62

3187 }
3188 const whereClause = convertWhereClause(model, where);
3189 const transformed = transformInput(update, model, "update");
→ 3190 const result = await db[getModelName(model)].update({
where: {
userId: "fa7vk3x8buBzHuwEecxPfelVvbPZEC9z",
? id?: String,
? AND?: TwoFactorWhereInput | TwoFactorWhereInput[],
? OR?: TwoFactorWhereInput[],
? NOT?: TwoFactorWhereInput | TwoFactorWhereInput[],
? secret?: StringFilter | String,
? backupCodes?: StringFilter | String,
? user?: UserScalarRelationFilter | UserWhereInput
},
data: {
backupCodes: "10bca1f7ea07176943d196cc5af8a935f852edd4cfec3c233f06d28bb80ee049aa9fd955130a1f85f3a6a85f95d6601724c21bea97e292dbaf3ddf8ceaf002226e26482345810211383e14c16bca8aa4699d13983f21618e16a0f483899c201f906f33bae7bd1345b56da3572258db6d78abace6165433c30596969c2afa1b62d59bf0427b5a8f61ecb1ee5124585c0728eb82787316aad1bbe3625237a1225d833a1babb85b5d3befd79c3c0a83dd6c83a404c968"
}
})

Argument `where` of type TwoFactorWhereUniqueInput needs at least one of `id` arguments. Available options are marked with ?.] {
clientVersion: '6.6.0'
}
# SERVER_ERROR: [Error [PrismaClientValidationError]:
Invalid `db[getModelName(model)].update()` invocation in
C:\Users\Admin\Desktop\LicensingWeb\my-app\.next\server\chunks\node_modules_better-auth_dist_e7fe42cb._.js:3190:62

3187 }
3188 const whereClause = convertWhereClause(model, where);
3189 const transformed = transformInput(update, model, "update");
→ 3190 const result = await db[getModelName(model)].update({
where: {
userId: "fa7vk3x8buBzHuwEecxPfelVvbPZEC9z",
? id?: String,
? AND?: TwoFactorWhereInput | TwoFactorWhereInput[],
? OR?: TwoFactorWhereInput[],
? NOT?: TwoFactorWhereInput | TwoFactorWhereInput[],
? secret?: StringFilter | String,
? backupCodes?: StringFilter | String,
? user?: UserScalarRelationFilter | UserWhereInput
},
data: {
backupCodes: "10bca1f7ea07176943d196cc5af8a935f852edd4cfec3c233f06d28bb80ee049aa9fd955130a1f85f3a6a85f95d6601724c21bea97e292dbaf3ddf8ceaf002226e26482345810211383e14c16bca8aa4699d13983f21618e16a0f483899c201f906f33bae7bd1345b56da3572258db6d78abace6165433c30596969c2afa1b62d59bf0427b5a8f61ecb1ee5124585c0728eb82787316aad1bbe3625237a1225d833a1babb85b5d3befd79c3c0a83dd6c83a404c968"
}
})

Argument `where` of type TwoFactorWhereUniqueInput needs at least one of `id` arguments. Available options are marked with ?.] {
clientVersion: '6.6.0'
}
Do you know why ?
try {
const { data, error } = await authClient.twoFactor.verifyTotp({
code: verificationCode
});

if (error) {
toast.error("Invalid verification code. Please try again.");
return;
}

// If verification is successful, generate backup codes
const backupCodesRes = await authClient.twoFactor.generateBackupCodes({
password: password
});

if (backupCodesRes.data?.backupCodes) {
setBackupCodes(backupCodesRes.data?.backupCodes || []);
setCurrentStep(3);
}
} catch (error) {
console.error("Error during verification:", error);
toast.error("Failed to verify code. Please try again.");
}
try {
const { data, error } = await authClient.twoFactor.verifyTotp({
code: verificationCode
});

if (error) {
toast.error("Invalid verification code. Please try again.");
return;
}

// If verification is successful, generate backup codes
const backupCodesRes = await authClient.twoFactor.generateBackupCodes({
password: password
});

if (backupCodesRes.data?.backupCodes) {
setBackupCodes(backupCodesRes.data?.backupCodes || []);
setCurrentStep(3);
}
} catch (error) {
console.error("Error during verification:", error);
toast.error("Failed to verify code. Please try again.");
}
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
One think. Im redoing the whole auth system. Should i authenticate users at server on client ?
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
😄 i forgot about this
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
yeah i will test this tomorrow
30 replies
BABetter Auth
Created by wvn on 4/8/2025 in #help
Admin Role
Yeah it is in the dtb
4 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
const [backupCodes, setBackupCodes] = useState<string[]>([]);

function generateBackupCodesFn(options?: BackupCodeOptions) {
return Array.from({ length: options?.amount ?? 10 })
.fill(null)
.map(() => generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z"))
.map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
}
setBackupCodes(generateBackupCodesFn());

<div className="grid grid-cols-2 gap-2">
{backupCodes.map((code, index) => (
<code key={index} className="text-sm font-mono">{code}</code>
))}
</div>
const [backupCodes, setBackupCodes] = useState<string[]>([]);

function generateBackupCodesFn(options?: BackupCodeOptions) {
return Array.from({ length: options?.amount ?? 10 })
.fill(null)
.map(() => generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z"))
.map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
}
setBackupCodes(generateBackupCodesFn());

<div className="grid grid-cols-2 gap-2">
{backupCodes.map((code, index) => (
<code key={index} className="text-sm font-mono">{code}</code>
))}
</div>
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
Yeah gemme minute my server is having big problems rn. Give me 5 minutes
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
The backup codes ?
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
And for the error ?
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
No description
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
await authClient.twoFactor.verifyBackupCode({code: "N5stL-xDSAJ"}, {
onSuccess(){
console.log("Success")
//redirect the user on success
},
onError(ctx){
alert(ctx.error.message)
}
})
await authClient.twoFactor.verifyBackupCode({code: "N5stL-xDSAJ"}, {
onSuccess(){
console.log("Success")
//redirect the user on success
},
onError(ctx){
alert(ctx.error.message)
}
})
# SERVER_ERROR: Error: padded hex string expected, got unpadded hex of length 191
at hexToBytes (../src/utils.ts:56:20)
POST /api/auth/two-factor/verify-backup-code 500 in 237ms
# SERVER_ERROR: Error: padded hex string expected, got unpadded hex of length 191
at hexToBytes (../src/utils.ts:56:20)
POST /api/auth/two-factor/verify-backup-code 500 in 237ms
undefined
undefined
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
Just wondering.. What is this ?
customBackupCodesGenerate?: () => string[];
customBackupCodesGenerate?: () => string[];
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
No description
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
Okay i will try to do this
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
That code is for generating.. But if i wanna check it i do
await authClient.twoFactor.verifyBackupCode({code: "j1rFA-Z3tNz"}, {
onSuccess(){
console.log("Success")
//redirect the user on success
},
onError(ctx){
alert(ctx.error.message)
}
})
await authClient.twoFactor.verifyBackupCode({code: "j1rFA-Z3tNz"}, {
onSuccess(){
console.log("Success")
//redirect the user on success
},
onError(ctx){
alert(ctx.error.message)
}
})
I do this ?
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
so the thing here is: should i push the backup code with the score ( like this XXXX-XXXX ) Or without? XXXXXXXX
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
No description
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Backup Verify
i will try it tomorrow
30 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
OTP
Im just stupid and used OTP instead of TOTP
4 replies
BABetter Auth
Created by wvn on 4/5/2025 in #help
Error generating backup codes
Yeah i switched to OTP
5 replies