email-verification-policy.ts 968 B

12345678910111213141516171819202122
  1. import { db } from './db'
  2. import { SYSTEM_SETTING_KEYS } from '@/features/admin/Schema/systemSettingsSchema'
  3. /**
  4. * Whether this install treats an email address as proved only after a link
  5. * sent to it was opened.
  6. *
  7. * Off by default on a self-hosted install, where there may be no mail server
  8. * at all and the people on it are the workshop's own. On means an address
  9. * is a claim until confirmed: changing it goes through a confirmation mail,
  10. * and inviting an address that an unconfirmed account holds mails the
  11. * address rather than seating the account. Read here, on the server, by
  12. * every action the answer changes; a page reading it on its own was a
  13. * promise the server did not keep.
  14. */
  15. export async function emailVerificationRequired(): Promise<boolean> {
  16. const setting = await db.systemSetting.findUnique({
  17. where: { key: SYSTEM_SETTING_KEYS.EMAIL_VERIFICATION_REQUIRED },
  18. select: { value: true },
  19. })
  20. return setting?.value === 'true'
  21. }