Files
payload/packages/translations
Said Akhrarov fd99a30bb6 feat: distinct error for unverified email login (#11647)
<!--

Thank you for the PR! Please go through the checklist below and make
sure you've completed all the steps.

Please review the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository if you haven't already.

The following items will ensure that your PR is handled as smoothly as
possible:

- PR Title must follow conventional commits format. For example, `feat:
my new feature`, `fix(plugin-seo): my fix`.
- Minimal description explained as if explained to someone not
immediately familiar with the code.
- Provide before/after screenshots or code diffs if applicable.
- Link any related issues/discussions from GitHub or Discord.
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Fixes #

-->
### What?
This PR adds a new error to be thrown when logging in while having
`verify: true` set but no email has been verified for the user yet.

### Why?
To have a more descriptive, actionable error thrown in this case as
opposed to the generic "Invalid email or password." This gives users
more insight into why the login failed.

### How?
Introducing a new error: `UnverifiedEmail` and adjusting the check to be
separate from `if (!user) { ... }`.

Fixes #11358

Notes:
- In terms of account enumeration: this should not be a concern here as
the check for throwing this error comes _after_ the check for valid args
as well as the find for the user. This means that credentials must be on
hand, both an email and password, before seeing this error.
- I have an int test written in `/test/auth/int.spec.ts` for this,
however whenever I try to commit it I get an error stating that the
`eslint@9.14.0` module was not found during `lint-staged`.

<details>
  <summary>Int test</summary>
  
  ```ts
it('should respond with unverifiedEmail if email is unverified on
login', async () => {
    await payload.create({
      collection: publicUsersSlug,
      data: {
        email: 'user@example.com',
        password: 'test',
      },
    })

const response = await restClient.POST(`/${publicUsersSlug}/login`, {
      body: JSON.stringify({
        email: 'user@example.com',
        password: 'test',
      }),
    })

    expect(response.status).toBe(403)

    const responseData = await response.json()
expect(responseData.errors[0].message).toBe('Please verify your email
before logging in.')
  })
  ```
  
</details>

Demo of toast:

![Login-Payload-03-11-2025_11_52_PM-unverified-after](https://github.com/user-attachments/assets/55112f61-1d1f-41b9-93e6-8a4d66365b81)
2025-03-18 15:52:51 -03:00
..

Payload Translations

The home of Payloads API and Admin Panel translations.

How to contribute

Updating a translation

  1. Update the translation value
  2. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    

Adding a new translation

  1. Add the new translation key/value pair for all languages located in the <payload-repo-root>/packages/translations/src/languages folder
  2. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    

Adding a new language

  1. Create a new TS file in the <payload-repo-root>/packages/translations/src/languages folder, use the language code as the file name (e.g. <payload-repo-root>/packages/translations/src/languages/en.ts for English)
  2. Copy all translations from an existing language file and update all of the translations to match your new language. Make sure the translation object containing all the translations is type DefaultTranslationsObject.
  3. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    
  4. Import and export your new language file from within <payload-repo-root>/packages/translations/src/exports/all.ts
  5. Re-export the file from within <payload-repo-root>/packages/payload/src/exports/i18n/[your-new-language].ts

Here is a full list of language keys. Note that these are not all implemented, but if you would like to contribute and add a new language, you can use this list as a reference:

Language Code Language Name
af Afrikaans
am Amharic
ar-sa Arabic (Saudi Arabia)
as Assamese
az-Latn Azerbaijani (Latin)
be Belarusian
bg Bulgarian
bn-BD Bangla (Bangladesh)
bn-IN Bangla (India)
bs Bosnian (Latin)
ca Catalan Spanish
ca-ES-valencia Valencian
cs Czech
cy Welsh
da Danish
de German (Germany)
el Greek
en-GB English (United Kingdom)
en-US English (United States)
es Spanish (Spain)
es-ES Spanish (Spain)
es-US Spanish (United States)
es-MX Spanish (Mexico)
et Estonian
eu Basque
fa Persian
fi Finnish
fil-Latn Filipino
fr French (France)
fr-FR French (France)
fr-CA French (Canada)
ga Irish
gd-Latn Scottish Gaelic
gl Galician
gu Gujarati
ha-Latn Hausa (Latin)
he Hebrew
hi Hindi
hr Croatian
hu Hungarian
hy Armenian
id Indonesian
ig-Latn Igbo
is Icelandic
it Italian (Italy)
it-it Italian (Italy)
ja Japanese
ka Georgian
kk Kazakh
km Khmer
kn Kannada
ko Korean
kok Konkani
ku-Arab Central Kurdish
ky-Cyrl Kyrgyz
lb Luxembourgish
lt Lithuanian
lv Latvian
mi-Latn Maori
mk Macedonian
ml Malayalam
mn-Cyrl Mongolian (Cyrillic)
mr Marathi
ms Malay (Malaysia)
mt Maltese
nb Norwegian (Bokmål)
ne Nepali (Nepal)
nl Dutch (Netherlands)
nl-BE Dutch (Netherlands)
nn Norwegian (Nynorsk)
nso Sesotho sa Leboa
or Odia
pa Punjabi (Gurmukhi)
pa-Arab Punjabi (Arabic)
pl Polish
prs-Arab Dari
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
qut-Latn Kiche
quz Quechua (Peru)
ro Romanian (Romania)
ru Russian
rw Kinyarwanda
sd-Arab Sindhi (Arabic)
si Sinhala
sk Slovak
sl Slovenian
sq Albanian
sr-Cyrl-BA Serbian (Cyrillic, Bosnia and Herzegovina)
sr-Cyrl-RS Serbian (Cyrillic, Serbia)
sr-Latn-RS Serbian (Latin, Serbia)
sv Swedish (Sweden)
sw Kiswahili
ta Tamil
te Telugu
tg-Cyrl Tajik (Cyrillic)
th Thai
ti Tigrinya
tk-Latn Turkmen (Latin)
tn Setswana
tr Turkish
tt-Cyrl Tatar (Cyrillic)
ug-Arab Uyghur
uk Ukrainian
ur Urdu
uz-Latn Uzbek (Latin)
vi Vietnamese
wo Wolof
xh isiXhosa
yo-Latn Yoruba
zh-Hans Chinese (Simplified)
zh-Hant Chinese (Traditional)
zu isiZulu