Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
const autoRemoveVerificationToken = ({ data, operation, originalDoc, value })=>{
|
|
// If a user manually sets `_verified` to true,
|
|
// and it was `false`, set _verificationToken to `null`.
|
|
// This is useful because the admin panel
|
|
// allows users to set `_verified` to true manually
|
|
if (operation === 'update') {
|
|
if (data?._verified === true && originalDoc?._verified === false) {
|
|
return null;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
export const verificationFields = [
|
|
{
|
|
name: '_verified',
|
|
type: 'checkbox',
|
|
access: {
|
|
create: ({ req: { user } })=>Boolean(user),
|
|
read: ({ req: { user } })=>Boolean(user),
|
|
update: ({ req: { user } })=>Boolean(user)
|
|
},
|
|
admin: {
|
|
components: {
|
|
Field: false
|
|
}
|
|
},
|
|
label: ({ t })=>t('authentication:verified')
|
|
},
|
|
{
|
|
name: '_verificationToken',
|
|
type: 'text',
|
|
hidden: true,
|
|
hooks: {
|
|
beforeChange: [
|
|
autoRemoveVerificationToken
|
|
]
|
|
}
|
|
}
|
|
];
|
|
|
|
//# sourceMappingURL=verification.js.map |