diff --git a/src/collections/initLocal.ts b/src/collections/initLocal.ts index b37ddc31a3..2d606af354 100644 --- a/src/collections/initLocal.ts +++ b/src/collections/initLocal.ts @@ -19,6 +19,9 @@ export default function initCollectionsLocal(ctx: Payload): void { if (collection.auth && !collection.auth.disableLocalStrategy) { schema.plugin(passportLocalMongoose, { usernameField: 'email', + errorMessages: { + UserExistsError: 'A user with the given email is already registered', + }, }); diff --git a/test/collections-graphql/int.spec.ts b/test/collections-graphql/int.spec.ts index 600f761aed..f57028ddf8 100644 --- a/test/collections-graphql/int.spec.ts +++ b/test/collections-graphql/int.spec.ts @@ -458,7 +458,7 @@ describe('collections-graphql', () => { expect(error.response.errors[1].message).toEqual('The following field is invalid: email'); expect(error.response.errors[1].path[0]).toEqual('test3'); expect(error.response.errors[1].extensions.name).toEqual('ValidationError'); - expect(error.response.errors[1].extensions.data[0].message).toEqual('A user with the given username is already registered'); + expect(error.response.errors[1].extensions.data[0].message).toEqual('A user with the given email is already registered'); expect(error.response.errors[1].extensions.data[0].field).toEqual('email'); }); }); diff --git a/yarn.lock b/yarn.lock index bc690d34bc..86a55bb1cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3417,7 +3417,7 @@ array.prototype.flat@^1.3.1: es-abstract "^1.20.4" es-shim-unscopables "^1.0.0" -array.prototype.flatmap@^1.3.1: +array.prototype.flatmap@^1.3.0, array.prototype.flatmap@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz#1aae7903c2100433cb8261cd4ed310aab5c4a183" integrity sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ== @@ -6443,6 +6443,17 @@ glob@^8.0.0, glob@^8.1.0: minimatch "^5.0.1" once "^1.3.0" +glob@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + global-dirs@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.1.tgz#0c488971f066baceda21447aecb1a8b911d22485" @@ -9574,7 +9585,7 @@ pino-std-serializers@^3.1.0: resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz#b56487c402d882eb96cd67c257868016b61ad671" integrity sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg== -pino@^6.4.1: +pino@^6.14.0: version "6.14.0" resolved "https://registry.yarnpkg.com/pino/-/pino-6.14.0.tgz#b745ea87a99a6c4c9b374e4f29ca7910d4c69f78" integrity sha512-iuhEDel3Z3hF9Jfe44DPXR8l07bhjuFY3GMHIXbjnY9XcafbyDDwl2sN2vw2GjMPf5Nkoe+OFao7ffn9SXaKDg==