@axiumine/koa-utils 5.0.3 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,14 @@ export interface IUserBaseSchema {
42
42
  accountValidDate?: Date;
43
43
  newsletter?: boolean;
44
44
  resetDateReq?: Date;
45
+ /**
46
+ * Password-reset token. Deliberately NOT `account.email.hash`: that slot belongs to the
47
+ * email-verification and email-change flows, which have a different lifetime (3 days vs 60
48
+ * minutes), a different throttle, and a different trust domain. While the two shared one
49
+ * field, requesting a reset silently invalidated a pending activation link, and a hash
50
+ * issued by either flow was accepted by the other.
51
+ */
52
+ resetHash?: string;
45
53
  disabled?: boolean;
46
54
  deleted?: boolean;
47
55
  };
@@ -79,10 +79,22 @@ const UserBaseSchema = new Schema({
79
79
  type: Date,
80
80
  required: false
81
81
  },
82
- disabled: {
82
+ resetHash: {
83
83
  type: String,
84
84
  required: false
85
85
  },
86
+ // Boolean, matching IUserBaseSchema. It was String, and that inverted the flag: a
87
+ // hydrated read (infoUserForLogin uses .exec(), not .lean()) cast a stored `false`
88
+ // to the string 'false', which is truthy, so every consumer's `if (account.disabled)`
89
+ // locked out a user explicitly marked NOT disabled. Writing `false` through Mongoose
90
+ // stored the string too. Existing rows holding 'true'/'false' strings must be
91
+ // migrated — run scripts/migrate-account-disabled-to-boolean.mjs. Mongoose repairs
92
+ // them on hydration, but .lean() readers (userData4VerifyEmail, emailChangeHashVerify)
93
+ // see the raw value and would still block on the string.
94
+ disabled: {
95
+ type: Boolean,
96
+ required: false
97
+ },
86
98
  deleted: {
87
99
  type: Boolean,
88
100
  required: false
@@ -1 +1 @@
1
- {"version":3,"file":"UserBase.mjs","sourceRoot":"","sources":["../../../../src/graphQL/models/MongoDB/UserBase.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAwD/C,MAAM,cAAc,GAA4B,IAAI,MAAM,CACzD;IAC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;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,YAAY,EAAE;gBACb,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,QAAQ,EAAE;gBACT,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,KAAK;aACf;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,YAAY,EAAE;QACb,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,IAAI,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,KAAK;KACf;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,MAAM;CAClB,CACD,CAAA;AAED,MAAM,QAAQ,GAAG,KAAK,CAAkB,UAAU,EAAE,cAAc,CAAC,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserForLogin {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\tpassword: string\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\temail: {\n\t\t\tvalid: boolean\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserBaseSchema {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\t_id?: boolean\n\t\temail: string\n\t\tpassword: string\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\t_id?: boolean\n\t\temail: {\n\t\t\t_id?: boolean\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t\thash?: string\n\t\t\tnewEmailTmp?: string\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData?: {\n\t\t_id: false\n\t\tname: string\n\t}\n\t__v?: number\n}\n\nconst UserBaseSchema: Schema<IUserBaseSchema> = new Schema(\n\t{\n\t\tlogin: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tfirstLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tlastLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\taccount: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\t_id: false,\n\t\t\t\t\t\tvalid: {\n\t\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\t\trequired: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdateLastReq: {\n\t\t\t\t\t\t\ttype: Date,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestTimes: {\n\t\t\t\t\t\t\ttype: Number,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\thash: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewEmailTmp: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tonboardingStep: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tonboardingDone: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\trememberMe: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tregistrationDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\taccountValidDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tnewsletter: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetDateReq: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdisabled: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdeleted: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\tpersonalData: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\tname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: false\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'user'\n\t}\n)\n\nconst UserBase = model<IUserBaseSchema>('UserBase', UserBaseSchema)\nexport { UserBase }\n"]}
1
+ {"version":3,"file":"UserBase.mjs","sourceRoot":"","sources":["../../../../src/graphQL/models/MongoDB/UserBase.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE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IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,IAAI;aACd;YACD,gBAAgB,EAAE;gBACjB,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,YAAY,EAAE;gBACb,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,SAAS,EAAE;gBACV,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,KAAK;aACf;YACD,kFAAkF;YAClF,mFAAmF;YACnF,sFAAsF;YACtF,qFAAqF;YACrF,8EAA8E;YAC9E,mFAAmF;YACnF,uFAAuF;YACvF,yDAAyD;YACzD,QAAQ,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,KAAK;aACf;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,YAAY,EAAE;QACb,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,IAAI,EAAE;gBACL,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,KAAK;KACf;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,MAAM;CAClB,CACD,CAAA;AAED,MAAM,QAAQ,GAAG,KAAK,CAAkB,UAAU,EAAE,cAAc,CAAC,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserForLogin {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\tpassword: string\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\temail: {\n\t\t\tvalid: boolean\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserBaseSchema {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\t_id?: boolean\n\t\temail: string\n\t\tpassword: string\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\t_id?: boolean\n\t\temail: {\n\t\t\t_id?: boolean\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t\thash?: string\n\t\t\tnewEmailTmp?: string\n\t\t}\n\t\tonboardingStep?: string\n\t\tonboardingDone?: boolean\n\t\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\t/**\n\t\t * Password-reset token. Deliberately NOT `account.email.hash`: that slot belongs to the\n\t\t * email-verification and email-change flows, which have a different lifetime (3 days vs 60\n\t\t * minutes), a different throttle, and a different trust domain. While the two shared one\n\t\t * field, requesting a reset silently invalidated a pending activation link, and a hash\n\t\t * issued by either flow was accepted by the other.\n\t\t */\n\t\tresetHash?: string\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData?: {\n\t\t_id: false\n\t\tname: string\n\t}\n\t__v?: number\n}\n\nconst UserBaseSchema: Schema<IUserBaseSchema> = new Schema(\n\t{\n\t\tlogin: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tfirstLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tlastLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\taccount: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\t_id: false,\n\t\t\t\t\t\tvalid: {\n\t\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\t\trequired: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdateLastReq: {\n\t\t\t\t\t\t\ttype: Date,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestTimes: {\n\t\t\t\t\t\t\ttype: Number,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\thash: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewEmailTmp: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tonboardingStep: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tonboardingDone: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\trememberMe: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tregistrationDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\taccountValidDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tnewsletter: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetDateReq: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetHash: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\t// Boolean, matching IUserBaseSchema. It was String, and that inverted the flag: a\n\t\t\t\t// hydrated read (infoUserForLogin uses .exec(), not .lean()) cast a stored `false`\n\t\t\t\t// to the string 'false', which is truthy, so every consumer's `if (account.disabled)`\n\t\t\t\t// locked out a user explicitly marked NOT disabled. Writing `false` through Mongoose\n\t\t\t\t// stored the string too. Existing rows holding 'true'/'false' strings must be\n\t\t\t\t// migrated — run scripts/migrate-account-disabled-to-boolean.mjs. Mongoose repairs\n\t\t\t\t// them on hydration, but .lean() readers (userData4VerifyEmail, emailChangeHashVerify)\n\t\t\t\t// see the raw value and would still block on the string.\n\t\t\t\tdisabled: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdeleted: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\tpersonalData: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\tname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: false\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'user'\n\t}\n)\n\nconst UserBase = model<IUserBaseSchema>('UserBase', UserBaseSchema)\nexport { UserBase }\n"]}
@@ -34,8 +34,11 @@ export const emailChangeHashVerify = {
34
34
  const { email, hash } = args;
35
35
  const uEmail = email.toLowerCase();
36
36
  // search if the email exists
37
+ // Every field this resolver reads must be listed. account.email.requestTimes was missing, and
38
+ // because this is a .lean() read the absent key made handleHashMismatch throw 500 on *every*
39
+ // wrong hash: the strike counter never advanced and the owner never got the wrongHash warning.
37
40
  const user = await UserBase.findOne({ 'account.email.newEmailTmp': uEmail })
38
- .select('_id account.email.hash account.email.dateLastReq account.deleted account.disabled')
41
+ .select('_id account.email.hash account.email.dateLastReq account.email.requestTimes account.deleted account.disabled')
39
42
  .lean();
40
43
  // if email not found, return
41
44
  if (user === null) {
@@ -69,6 +72,9 @@ export const emailChangeHashVerify = {
69
72
  return false;
70
73
  }
71
74
  // account is deleted -> maybe by admin for any reason
75
+ // Read raw: this is a .lean() query, so Mongoose casting never runs and these are real
76
+ // booleans only on data that scripts/migrate-account-disabled-to-boolean.mjs has been
77
+ // through. A legacy string 'false' is truthy and blocks here — migrate, don't coerce.
72
78
  else if (user.account.deleted) {
73
79
  return false;
74
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"emailChangeHashVerify.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/emailChangeHashVerify.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,yCAAgC;AACxD,OAAO,EAAE,SAAS,EAAE,mCAA0B;AAC9C,OAAO,EAAE,QAAQ,EAAE,0CAAoC;AACvD,OAAO,eAAe,2DAAkD;AACxE,OAAO,EAAE,WAAW,EAAE,uDAA8C;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAqC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQvE;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAChC,GAAmB,EACnB,MAAc,EACd,YAAgC,EAChC,aAA4B;IAE5B,cAAc;IACd,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAE5B,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;QACzC,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAED,MAAM,WAAW,CAAC,GAAG,CAAC,CAAA;IACtB,+BAA+B;IAC/B,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAC7C,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,WAAW,EAAE,oDAAoD;IACjE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,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AE,aAAa,CAAC,CAAA;QACtF,CAAC;IACF,CAAC;CACD,CAAA","sourcesContent":["import { SocketLabsLib } from '@email/SocketLabsLib.mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport confirmNewEmail from '@private/lib/access/db/confirmNewEmail.mjs'\nimport { incReqTimes } from '@private/lib/access/db/incReqTimes.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLString } from 'graphql'\nimport { Types } from 'mongoose'\n\ninterface IArgs {\n\temail: string\n\thash: string\n}\n\n/**\n * The submitted hash does not match the stored one: count the attempt and warn the account owner.\n * Extracted from resolve() only to keep it inside the max-lines-per-function budget — behaviour unchanged.\n */\nasync function handleHashMismatch(\n\tuId: Types.ObjectId,\n\tuEmail: string,\n\trequestTimes: number | undefined,\n\tSocketLabsObj: SocketLabsLib\n) {\n\t// hash failed\n\tconsole.debug('HASH FAILED')\n\n\tif (typeof requestTimes === 'undefined') {\n\t\tthrow throwInternalError()\n\t}\n\n\tawait incReqTimes(uId)\n\t// noinspection ES6MissingAwait\n\tSocketLabsObj.wrongHash(uEmail, requestTimes)\n\treturn false\n}\n\n/**\n * Change email - Verify match between email and hash\n */\nexport const emailChangeHashVerify = {\n\tdescription: 'Change email - Verify match between email and hash',\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\thash: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: IArgs) {\n\t\tconst { email, hash } = args\n\t\tconst uEmail = email.toLowerCase()\n\n\t\t// search if the email exists\n\t\tconst user = await UserBase.findOne({ 'account.email.newEmailTmp': uEmail })\n\t\t\t.select('_id account.email.hash account.email.dateLastReq account.deleted account.disabled')\n\t\t\t.lean()\n\n\t\t// if email not found, return\n\t\tif (user === null) {\n\t\t\t// <- not found or wrong, do not say to the user the real problem !\n\t\t\tconsole.debug('email NOT found ', uEmail)\n\n\t\t\treturn false // @fixme throw\n\t\t}\n\t\tconsole.debug('email found')\n\n\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\tconst StrLibObj = new StringLib()\n\n\t\tconsole.debug('comparing hash ')\n\t\tconst accountEmail = user.account.email\n\t\tif (hash === accountEmail.hash) {\n\t\t\tif (typeof accountEmail.dateLastReq === 'undefined') {\n\t\t\t\t// @fixme sentry 'dateLastReq is undefined'\n\t\t\t\tthrow throwInternalError()\n\t\t\t}\n\n\t\t\tconsole.debug('activation link hash is valid')\n\t\t\t/****************************************************\n\t\t\t * if dateLastReq too old then 3 days send email\n\t\t\t */\n\n\t\t\tconst now = new Date()\n\t\t\tconst day3ago = new Date(now.setDate(now.getDate() - 3))\n\t\t\tconst tsReq = StrLibObj.isoToTimestamp(accountEmail.dateLastReq)\n\t\t\tconst ts3DayAgo = StrLibObj.isoToTimestamp(day3ago)\n\n\t\t\tif (ts3DayAgo > tsReq) {\n\t\t\t\t// dateLastReq too old then 3 days\n\t\t\t\tconsole.debug('but link is too old')\n\n\t\t\t\t// noinspection ES6MissingAwait\n\t\t\t\tSocketLabsObj.hashReqTooOld(uEmail)\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// account is deleted -> maybe by admin for any reason\n\t\t\telse if (user.account.deleted) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// if account is disabled, for any reason\n\t\t\telse if (user.account.disabled) {\n\t\t\t\t// noinspection ES6MissingAwait\n\t\t\t\tSocketLabsObj.accountDisabled(uEmail)\n\t\t\t\treturn false\n\t\t\t} else {\n\t\t\t\t// valid request. is this email free ?\n\n\t\t\t\t// meanwhile, has some user registered with this email address ??\n\t\t\t\tconst qty = await UserBase.countDocuments({ 'login.email': uEmail })\n\n\t\t\t\tif (qty === 0) {\n\t\t\t\t\t// accept new email\n\t\t\t\t\tawait confirmNewEmail(user._id, uEmail)\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn handleHashMismatch(user._id, uEmail, accountEmail.requestTimes, SocketLabsObj)\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"emailChangeHashVerify.mjs","sourceRoot":"","sources":["../../../../src/graphQL/schema/mutations/emailChangeHashVerify.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,yCAAgC;AACxD,OAAO,EAAE,SAAS,EAAE,mCAA0B;AAC9C,OAAO,EAAE,QAAQ,EAAE,0CAAoC;AACvD,OAAO,eAAe,2DAAkD;AACxE,OAAO,EAAE,WAAW,EAAE,uDAA8C;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAqC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQvE;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAChC,GAAmB,EACnB,MAAc,EACd,YAAgC,EAChC,aAA4B;IAE5B,cAAc;IACd,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAE5B,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;QACzC,MAAM,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAED,MAAM,WAAW,CAAC,GAAG,CAAC,CAAA;IACtB,+BAA+B;IAC/B,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAC7C,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,WAAW,EAAE,oDAAoD;IACjE,IAAI,EAAE,IAAI,cAAc,CAAC,cAAc,CAAC;IACxC,IAAI,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;QAClD,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE;KACjD;IACD,KAAK,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mjs'\nimport { StringLib } from '@lib/StringLib.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport confirmNewEmail from '@private/lib/access/db/confirmNewEmail.mjs'\nimport { incReqTimes } from '@private/lib/access/db/incReqTimes.mjs'\nimport { throwInternalError } from '@throw/throwInternalError.mjs'\nimport { GraphQLBoolean, GraphQLNonNull, GraphQLString } from 'graphql'\nimport { Types } from 'mongoose'\n\ninterface IArgs {\n\temail: string\n\thash: string\n}\n\n/**\n * The submitted hash does not match the stored one: count the attempt and warn the account owner.\n * Extracted from resolve() only to keep it inside the max-lines-per-function budget — behaviour unchanged.\n */\nasync function handleHashMismatch(\n\tuId: Types.ObjectId,\n\tuEmail: string,\n\trequestTimes: number | undefined,\n\tSocketLabsObj: SocketLabsLib\n) {\n\t// hash failed\n\tconsole.debug('HASH FAILED')\n\n\tif (typeof requestTimes === 'undefined') {\n\t\tthrow throwInternalError()\n\t}\n\n\tawait incReqTimes(uId)\n\t// noinspection ES6MissingAwait\n\tSocketLabsObj.wrongHash(uEmail, requestTimes)\n\treturn false\n}\n\n/**\n * Change email - Verify match between email and hash\n */\nexport const emailChangeHashVerify = {\n\tdescription: 'Change email - Verify match between email and hash',\n\ttype: new GraphQLNonNull(GraphQLBoolean),\n\targs: {\n\t\temail: { type: new GraphQLNonNull(GraphQLString) },\n\t\thash: { type: new GraphQLNonNull(GraphQLString) }\n\t},\n\tasync resolve(_: unknown, args: IArgs) {\n\t\tconst { email, hash } = args\n\t\tconst uEmail = email.toLowerCase()\n\n\t\t// search if the email exists\n\t\t// Every field this resolver reads must be listed. account.email.requestTimes was missing, and\n\t\t// because this is a .lean() read the absent key made handleHashMismatch throw 500 on *every*\n\t\t// wrong hash: the strike counter never advanced and the owner never got the wrongHash warning.\n\t\tconst user = await UserBase.findOne({ 'account.email.newEmailTmp': uEmail })\n\t\t\t.select('_id account.email.hash account.email.dateLastReq account.email.requestTimes account.deleted account.disabled')\n\t\t\t.lean()\n\n\t\t// if email not found, return\n\t\tif (user === null) {\n\t\t\t// <- not found or wrong, do not say to the user the real problem !\n\t\t\tconsole.debug('email NOT found ', uEmail)\n\n\t\t\treturn false // @fixme throw\n\t\t}\n\t\tconsole.debug('email found')\n\n\t\tconst SocketLabsObj = new SocketLabsLib()\n\t\tconst StrLibObj = new StringLib()\n\n\t\tconsole.debug('comparing hash ')\n\t\tconst accountEmail = user.account.email\n\t\tif (hash === accountEmail.hash) {\n\t\t\tif (typeof accountEmail.dateLastReq === 'undefined') {\n\t\t\t\t// @fixme sentry 'dateLastReq is undefined'\n\t\t\t\tthrow throwInternalError()\n\t\t\t}\n\n\t\t\tconsole.debug('activation link hash is valid')\n\t\t\t/****************************************************\n\t\t\t * if dateLastReq too old then 3 days send email\n\t\t\t */\n\n\t\t\tconst now = new Date()\n\t\t\tconst day3ago = new Date(now.setDate(now.getDate() - 3))\n\t\t\tconst tsReq = StrLibObj.isoToTimestamp(accountEmail.dateLastReq)\n\t\t\tconst ts3DayAgo = StrLibObj.isoToTimestamp(day3ago)\n\n\t\t\tif (ts3DayAgo > tsReq) {\n\t\t\t\t// dateLastReq too old then 3 days\n\t\t\t\tconsole.debug('but link is too old')\n\n\t\t\t\t// noinspection ES6MissingAwait\n\t\t\t\tSocketLabsObj.hashReqTooOld(uEmail)\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// account is deleted -> maybe by admin for any reason\n\t\t\t// Read raw: this is a .lean() query, so Mongoose casting never runs and these are real\n\t\t\t// booleans only on data that scripts/migrate-account-disabled-to-boolean.mjs has been\n\t\t\t// through. A legacy string 'false' is truthy and blocks here — migrate, don't coerce.\n\t\t\telse if (user.account.deleted) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// if account is disabled, for any reason\n\t\t\telse if (user.account.disabled) {\n\t\t\t\t// noinspection ES6MissingAwait\n\t\t\t\tSocketLabsObj.accountDisabled(uEmail)\n\t\t\t\treturn false\n\t\t\t} else {\n\t\t\t\t// valid request. is this email free ?\n\n\t\t\t\t// meanwhile, has some user registered with this email address ??\n\t\t\t\tconst qty = await UserBase.countDocuments({ 'login.email': uEmail })\n\n\t\t\t\tif (qty === 0) {\n\t\t\t\t\t// accept new email\n\t\t\t\t\tawait confirmNewEmail(user._id, uEmail)\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn handleHashMismatch(user._id, uEmail, accountEmail.requestTimes, SocketLabsObj)\n\t\t}\n\t}\n}\n"]}
@@ -71,8 +71,12 @@ const UserAdminKoaUtilsSchema = new Schema({
71
71
  type: Date,
72
72
  required: false
73
73
  },
74
+ // Boolean, matching IUserAdminKoaUtilsSchema — same fix as UserBase. As String, a
75
+ // stored `false` hydrated to the truthy string 'false' and infoUserAdminForLogin
76
+ // locked out admins who were explicitly not disabled. Existing rows need
77
+ // scripts/migrate-account-disabled-to-boolean.mjs, which covers this collection too.
74
78
  disabled: {
75
- type: String,
79
+ type: Boolean,
76
80
  required: false
77
81
  },
78
82
  deleted: {
@@ -1 +1 @@
1
- {"version":3,"file":"UserAdminKoaUtils.mjs","sourceRoot":"","sources":["../../../../../../src/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAqD/C,MAAM,uBAAuB,GAAqC,IAAI,MAAM,CAC3E;IACC,KAAK,EAAE;QACN,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,QAAQ,EAAE;gBACT,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,SAAS,EAAE;gBACV,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;SACD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O,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,WAAW;CACvB,CACD,CAAA;AAED,eAAe,KAAK,CAA2B,mBAAmB,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserAdminForLogin {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\tpassword: string\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\temail: {\n\t\t\tvalid: boolean\n\t\t}\n\t\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserAdminKoaUtilsSchema {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\t_id?: boolean\n\t\temail: string\n\t\tpassword: string\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\t_id?: boolean\n\t\temail: {\n\t\t\t_id?: boolean\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t\thash?: string\n\t\t\tnewEmailTmp?: string\n\t\t}\n\t\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData: {\n\t\t_id: false\n\t\tname: string\n\t\tsurname: string\n\t}\n\t__v?: number\n}\n\nconst UserAdminKoaUtilsSchema: Schema<IUserAdminKoaUtilsSchema> = new Schema(\n\t{\n\t\tlogin: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tfirstLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tlastLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\taccount: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\t_id: false,\n\t\t\t\t\t\tvalid: {\n\t\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\t\trequired: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdateLastReq: {\n\t\t\t\t\t\t\ttype: Date,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestTimes: {\n\t\t\t\t\t\t\ttype: Number,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\thash: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewEmailTmp: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\trememberMe: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tregistrationDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\taccountValidDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tnewsletter: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetDateReq: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdisabled: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdeleted: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\tpersonalData: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\tname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tsurname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'userAdmin'\n\t}\n)\n\nexport default model<IUserAdminKoaUtilsSchema>('UserAdminKoaUtils', UserAdminKoaUtilsSchema)\n"]}
1
+ {"version":3,"file":"UserAdminKoaUtils.mjs","sourceRoot":"","sources":["../../../../../../src/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAqD/C,MAAM,uBAAuB,GAAqC,IAAI,MAAM,CAC3E;IACC,KAAK,EAAE;QACN,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,QAAQ,EAAE;gBACT,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,UAAU,EAAE;gBACX,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;YACD,SAAS,EAAE;gBACV,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aACf;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE;YACL,GAAG,EAAE,KAAK;YACV,KAAK,EAAE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,EAAE,IAAI;aACd;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KACf;CACD,EACD;IACC,UAAU,EAAE,WAAW;CACvB,CACD,CAAA;AAED,eAAe,KAAK,CAA2B,mBAAmB,EAAE,uBAAuB,CAAC,CAAA","sourcesContent":["import { model, Schema, Types } from 'mongoose'\n\nexport interface IInfoUserAdminForLogin {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\tpassword: string\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\temail: {\n\t\t\tvalid: boolean\n\t\t}\n\t\trememberMe?: boolean\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n}\n\nexport interface IUserAdminKoaUtilsSchema {\n\t_id: Types.ObjectId\n\tlogin: {\n\t\t_id?: boolean\n\t\temail: string\n\t\tpassword: string\n\t\tfirstLogin?: Date\n\t\tlastLogin?: Date\n\t}\n\taccount: {\n\t\t_id?: boolean\n\t\temail: {\n\t\t\t_id?: boolean\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t\thash?: string\n\t\t\tnewEmailTmp?: string\n\t\t}\n\t\trememberMe?: boolean\n\t\tregistrationDate: Date\n\t\taccountValidDate?: Date\n\t\tnewsletter?: boolean\n\t\tresetDateReq?: Date\n\t\tdisabled?: boolean\n\t\tdeleted?: boolean\n\t}\n\tpersonalData: {\n\t\t_id: false\n\t\tname: string\n\t\tsurname: string\n\t}\n\t__v?: number\n}\n\nconst UserAdminKoaUtilsSchema: Schema<IUserAdminKoaUtilsSchema> = new Schema(\n\t{\n\t\tlogin: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tfirstLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tlastLogin: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\taccount: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\temail: {\n\t\t\t\t\ttype: {\n\t\t\t\t\t\t_id: false,\n\t\t\t\t\t\tvalid: {\n\t\t\t\t\t\t\ttype: Boolean,\n\t\t\t\t\t\t\trequired: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdateLastReq: {\n\t\t\t\t\t\t\ttype: Date,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestTimes: {\n\t\t\t\t\t\t\ttype: Number,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\thash: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewEmailTmp: {\n\t\t\t\t\t\t\ttype: String,\n\t\t\t\t\t\t\trequired: false\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\trememberMe: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tregistrationDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\taccountValidDate: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tnewsletter: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tresetDateReq: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\t// Boolean, matching IUserAdminKoaUtilsSchema — same fix as UserBase. As String, a\n\t\t\t\t// stored `false` hydrated to the truthy string 'false' and infoUserAdminForLogin\n\t\t\t\t// locked out admins who were explicitly not disabled. Existing rows need\n\t\t\t\t// scripts/migrate-account-disabled-to-boolean.mjs, which covers this collection too.\n\t\t\t\tdisabled: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t},\n\t\t\t\tdeleted: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\trequired: false\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\tpersonalData: {\n\t\t\ttype: {\n\t\t\t\t_id: false,\n\t\t\t\tname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t},\n\t\t\t\tsurname: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\trequired: true\n\t\t\t\t}\n\t\t\t},\n\t\t\trequired: true\n\t\t},\n\t\t__v: {\n\t\t\ttype: Number,\n\t\t\trequired: false\n\t\t}\n\t},\n\t{\n\t\tcollection: 'userAdmin'\n\t}\n)\n\nexport default model<IUserAdminKoaUtilsSchema>('UserAdminKoaUtils', UserAdminKoaUtilsSchema)\n"]}
@@ -38,6 +38,10 @@ export async function assertVerifyEmailAllowed(user, email, hash) {
38
38
  // dbHash is the value STORED for this account — never the one supplied in the URL
39
39
  await handleIfHashBad({ uId, uEmail: email, hash, requestTimes, dbHash: userAccountEmail.hash });
40
40
  await handleIfMoreThan3DaysPassed(email, dateLastReq);
41
+ // The flags are passed raw. userData4VerifyEmail reads .lean(), so Mongoose casting never runs
42
+ // and these are exactly what the driver found — which is only ever a boolean once
43
+ // scripts/migrate-account-disabled-to-boolean.mjs has run. On un-migrated data a stored 'false'
44
+ // is a truthy string and blocks the account; the fix is the migration, not a coercion here.
41
45
  await handleIfAccountDeleted(email, deleted);
42
46
  await handleIfAccountDisabled(email, disabled);
43
47
  return uId;
@@ -1 +1 @@
1
- {"version":3,"file":"assertVerifyEmailAllowed.mjs","sourceRoot":"","sources":["../../../../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D,MAAM,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC5C,MAAM,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAE9C,OAAO,GAAG,CAAA;AACX,CAAC","sourcesContent":["import { Types } from 'mongoose'\n\nimport { handleBadDB } from './handleBadDB.mjs'\nimport { handleIfAccountDeleted } from './handleIfAccountDeleted.mjs'\nimport { handleIfAccountDisabled } from './handleIfAccountDisabled.mjs'\nimport { handleIfEmailAlreadyValid } from './handleIfEmailAlreadyValid.mjs'\nimport { handleIfHashBad } from './handleIfHashBad.mjs'\nimport { handleIfMoreThan3DaysPassed } from './handleIfMoreThan3DaysPassed.mjs'\nimport { handleIfTooMuchRequestsTimes } from './handleIfTooMuchRequestsTimes.mjs'\n\n/** The projection userData4VerifyEmail selects, as the guard chain needs it. */\nexport interface IVerifyEmailUser {\n\t_id: Types.ObjectId\n\taccount: {\n\t\temail: {\n\t\t\thash?: string\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t}\n\t\tdeleted?: boolean\n\t\tdisabled?: boolean\n\t}\n}\n\n/**\n * Run every guard that must pass before an email-verification link is honoured, in order.\n *\n * Extracted from routerVerifyEmail so the sequence is reachable by tests. Inside the\n * router it was not: the handler's only entry point performs a DB read, which cannot be\n * stubbed under the tsx loader (ESM live bindings), so in the suite it always rejected\n * and the whole try-body was dead code — sitting under a `c8 ignore` besides. Mutation\n * testing confirmed the cost: deleting the disabled-account guard, negating the deleted\n * flag, comparing the URL hash against ITSELF instead of the stored one, hard-coding\n * requestTimes to 0, and dropping the `await` on the hash check ALL left the suite green.\n * Each guard had thorough unit tests of its own; nothing tested that the router called\n * them, with the right values, in the right order.\n *\n * Throws (via the handleIf* guards) when the link must not be honoured. Returns the user\n * id to enable when every guard passes.\n *\n * Enabling the account is deliberately NOT done here. The caller performs it on the\n * returned id, so the irreversible side effect cannot be reordered ahead of a guard —\n * a mutation that did exactly that also survived.\n */\nexport async function assertVerifyEmailAllowed(user: IVerifyEmailUser, email: string, hash: string): Promise<Types.ObjectId> {\n\tconst uId = user._id\n\tconst userAccount = user.account\n\tconst userAccountEmail = userAccount.email\n\tconst requestTimes = userAccountEmail.requestTimes\n\tconst dateLastReq = userAccountEmail.dateLastReq\n\tconst { deleted, disabled } = userAccount\n\n\tawait handleIfEmailAlreadyValid(email, userAccountEmail.valid)\n\thandleBadDB(requestTimes, dateLastReq)\n\tawait handleIfTooMuchRequestsTimes(email, requestTimes)\n\t// dbHash is the value STORED for this account — never the one supplied in the URL\n\tawait handleIfHashBad({ uId, uEmail: email, hash, requestTimes, dbHash: userAccountEmail.hash })\n\n\tawait handleIfMoreThan3DaysPassed(email, dateLastReq)\n\tawait handleIfAccountDeleted(email, deleted)\n\tawait handleIfAccountDisabled(email, disabled)\n\n\treturn uId\n}\n"]}
1
+ {"version":3,"file":"assertVerifyEmailAllowed.mjs","sourceRoot":"","sources":["../../../../src/private/lib/access/assertVerifyEmailAllowed.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAA;AAiBjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAsB,EAAE,KAAa,EAAE,IAAY;IACjG,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAA;IAChC,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAA;IAC1C,MAAM,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAA;IAClD,MAAM,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAA;IAChD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAA;IAEzC,MAAM,yBAAyB,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAC9D,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;IACtC,MAAM,4BAA4B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IACvD,kFAAkF;IAClF,MAAM,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAA;IAEhG,MAAM,2BAA2B,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IACrD,+FAA+F;IAC/F,kFAAkF;IAClF,gGAAgG;IAChG,4FAA4F;IAC5F,MAAM,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC5C,MAAM,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAE9C,OAAO,GAAG,CAAA;AACX,CAAC","sourcesContent":["import { Types } from 'mongoose'\n\nimport { handleBadDB } from './handleBadDB.mjs'\nimport { handleIfAccountDeleted } from './handleIfAccountDeleted.mjs'\nimport { handleIfAccountDisabled } from './handleIfAccountDisabled.mjs'\nimport { handleIfEmailAlreadyValid } from './handleIfEmailAlreadyValid.mjs'\nimport { handleIfHashBad } from './handleIfHashBad.mjs'\nimport { handleIfMoreThan3DaysPassed } from './handleIfMoreThan3DaysPassed.mjs'\nimport { handleIfTooMuchRequestsTimes } from './handleIfTooMuchRequestsTimes.mjs'\n\n/** The projection userData4VerifyEmail selects, as the guard chain needs it. */\nexport interface IVerifyEmailUser {\n\t_id: Types.ObjectId\n\taccount: {\n\t\temail: {\n\t\t\thash?: string\n\t\t\tvalid: boolean\n\t\t\tdateLastReq?: Date\n\t\t\trequestTimes?: number\n\t\t}\n\t\tdeleted?: boolean\n\t\tdisabled?: boolean\n\t}\n}\n\n/**\n * Run every guard that must pass before an email-verification link is honoured, in order.\n *\n * Extracted from routerVerifyEmail so the sequence is reachable by tests. Inside the\n * router it was not: the handler's only entry point performs a DB read, which cannot be\n * stubbed under the tsx loader (ESM live bindings), so in the suite it always rejected\n * and the whole try-body was dead code — sitting under a `c8 ignore` besides. Mutation\n * testing confirmed the cost: deleting the disabled-account guard, negating the deleted\n * flag, comparing the URL hash against ITSELF instead of the stored one, hard-coding\n * requestTimes to 0, and dropping the `await` on the hash check ALL left the suite green.\n * Each guard had thorough unit tests of its own; nothing tested that the router called\n * them, with the right values, in the right order.\n *\n * Throws (via the handleIf* guards) when the link must not be honoured. Returns the user\n * id to enable when every guard passes.\n *\n * Enabling the account is deliberately NOT done here. The caller performs it on the\n * returned id, so the irreversible side effect cannot be reordered ahead of a guard —\n * a mutation that did exactly that also survived.\n */\nexport async function assertVerifyEmailAllowed(user: IVerifyEmailUser, email: string, hash: string): Promise<Types.ObjectId> {\n\tconst uId = user._id\n\tconst userAccount = user.account\n\tconst userAccountEmail = userAccount.email\n\tconst requestTimes = userAccountEmail.requestTimes\n\tconst dateLastReq = userAccountEmail.dateLastReq\n\tconst { deleted, disabled } = userAccount\n\n\tawait handleIfEmailAlreadyValid(email, userAccountEmail.valid)\n\thandleBadDB(requestTimes, dateLastReq)\n\tawait handleIfTooMuchRequestsTimes(email, requestTimes)\n\t// dbHash is the value STORED for this account — never the one supplied in the URL\n\tawait handleIfHashBad({ uId, uEmail: email, hash, requestTimes, dbHash: userAccountEmail.hash })\n\n\tawait handleIfMoreThan3DaysPassed(email, dateLastReq)\n\t// The flags are passed raw. userData4VerifyEmail reads .lean(), so Mongoose casting never runs\n\t// and these are exactly what the driver found — which is only ever a boolean once\n\t// scripts/migrate-account-disabled-to-boolean.mjs has run. On un-migrated data a stored 'false'\n\t// is a truthy string and blocks the account; the fix is the migration, not a coercion here.\n\tawait handleIfAccountDeleted(email, deleted)\n\tawait handleIfAccountDisabled(email, disabled)\n\n\treturn uId\n}\n"]}
@@ -2,7 +2,7 @@ import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
2
2
  export const getResetPwd = async function (session, email) {
3
3
  let ret = null;
4
4
  const queryRet = await UserBase.findOne({ 'login.email': email })
5
- .select('_id personalData.name account.resetDateReq account.email.hash')
5
+ .select('_id personalData.name account.resetDateReq account.resetHash')
6
6
  .session(session)
7
7
  .lean();
8
8
  // if a reset request is found
@@ -10,12 +10,12 @@ export const getResetPwd = async function (session, email) {
10
10
  const resetDateReq = queryRet.account.resetDateReq;
11
11
  let resetHash = null;
12
12
  if (typeof resetDateReq !== 'undefined') {
13
- const storedHash = queryRet.account.email.hash;
14
- // Never stringify: account.email.hash is a slot shared with the email-verification and
15
- // email-change flows, so enableEmailAccess / confirmNewEmail can clear it while
16
- // account.resetDateReq survives. '' + undefined yields the literal string "undefined",
17
- // which passed updatePassword's null check and then matched a caller sending that same
18
- // literal as the hash argument — a reset with no secret at all. Absent hash => null,
13
+ const storedHash = queryRet.account.resetHash;
14
+ // Never stringify, and never fall back to account.email.hash. '' + undefined yields the
15
+ // literal string "undefined", which passed updatePassword's null check and then matched a
16
+ // caller sending that same literal as the hash argument — a reset with no secret at all.
17
+ // The two fields must also stay disjoint: reading the verification slot here is what let a
18
+ // hash issued by one flow authenticate the other. Anything but a stored string => null,
19
19
  // which updatePassword rejects with a 500.
20
20
  if (typeof storedHash === 'string') {
21
21
  resetHash = storedHash;
@@ -1 +1 @@
1
- {"version":3,"file":"getResetPwd.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/getResetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,WAAW,OAAsB,EAAE,KAAa;IAC/E,IAAI,GAAG,GAAG,IAAI,CAAA;IAEd,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SAC/D,MAAM,CAAC,+DAA+D,CAAC;SACvE,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,8BAA8B;IAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAA;QAClD,IAAI,SAAS,GAAG,IAAI,CAAA;QAEpB,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;YAE9C,uFAAuF;YACvF,gFAAgF;YAChF,uFAAuF;YACvF,uFAAuF;YACvF,qFAAqF;YACrF,2CAA2C;YAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACpC,SAAS,GAAG,UAAU,CAAA;YACvB,CAAC;QACF,CAAC;QAED,GAAG,GAAG;YACL,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,YAAY;YACZ,SAAS;YACT,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;SACvC,CAAA;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport const getResetPwd = async function (session: ClientSession, email: string) {\n\tlet ret = null\n\n\tconst queryRet = await UserBase.findOne({ 'login.email': email })\n\t\t.select('_id personalData.name account.resetDateReq account.email.hash')\n\t\t.session(session)\n\t\t.lean()\n\n\t// if a reset request is found\n\tif (queryRet !== null) {\n\t\tconst resetDateReq = queryRet.account.resetDateReq\n\t\tlet resetHash = null\n\n\t\tif (typeof resetDateReq !== 'undefined') {\n\t\t\tconst storedHash = queryRet.account.email.hash\n\n\t\t\t// Never stringify: account.email.hash is a slot shared with the email-verification and\n\t\t\t// email-change flows, so enableEmailAccess / confirmNewEmail can clear it while\n\t\t\t// account.resetDateReq survives. '' + undefined yields the literal string \"undefined\",\n\t\t\t// which passed updatePassword's null check and then matched a caller sending that same\n\t\t\t// literal as the hash argument — a reset with no secret at all. Absent hash => null,\n\t\t\t// which updatePassword rejects with a 500.\n\t\t\tif (typeof storedHash === 'string') {\n\t\t\t\tresetHash = storedHash\n\t\t\t}\n\t\t}\n\n\t\tret = {\n\t\t\t_id: queryRet._id,\n\t\t\tresetDateReq,\n\t\t\tresetHash,\n\t\t\tname: queryRet.personalData?.name || ''\n\t\t}\n\t}\n\treturn ret\n}\n"]}
1
+ {"version":3,"file":"getResetPwd.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/getResetPwd.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,WAAW,OAAsB,EAAE,KAAa;IAC/E,IAAI,GAAG,GAAG,IAAI,CAAA;IAEd,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;SAC/D,MAAM,CAAC,8DAA8D,CAAC;SACtE,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;IAER,8BAA8B;IAC9B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAA;QAClD,IAAI,SAAS,GAAG,IAAI,CAAA;QAEpB,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAA;YAE7C,wFAAwF;YACxF,0FAA0F;YAC1F,yFAAyF;YACzF,2FAA2F;YAC3F,wFAAwF;YACxF,2CAA2C;YAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACpC,SAAS,GAAG,UAAU,CAAA;YACvB,CAAC;QACF,CAAC;QAED,GAAG,GAAG;YACL,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,YAAY;YACZ,SAAS;YACT,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,IAAI,IAAI,EAAE;SACvC,CAAA;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC,CAAA","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport const getResetPwd = async function (session: ClientSession, email: string) {\n\tlet ret = null\n\n\tconst queryRet = await UserBase.findOne({ 'login.email': email })\n\t\t.select('_id personalData.name account.resetDateReq account.resetHash')\n\t\t.session(session)\n\t\t.lean()\n\n\t// if a reset request is found\n\tif (queryRet !== null) {\n\t\tconst resetDateReq = queryRet.account.resetDateReq\n\t\tlet resetHash = null\n\n\t\tif (typeof resetDateReq !== 'undefined') {\n\t\t\tconst storedHash = queryRet.account.resetHash\n\n\t\t\t// Never stringify, and never fall back to account.email.hash. '' + undefined yields the\n\t\t\t// literal string \"undefined\", which passed updatePassword's null check and then matched a\n\t\t\t// caller sending that same literal as the hash argument — a reset with no secret at all.\n\t\t\t// The two fields must also stay disjoint: reading the verification slot here is what let a\n\t\t\t// hash issued by one flow authenticate the other. Anything but a stored string => null,\n\t\t\t// which updatePassword rejects with a 500.\n\t\t\tif (typeof storedHash === 'string') {\n\t\t\t\tresetHash = storedHash\n\t\t\t}\n\t\t}\n\n\t\tret = {\n\t\t\t_id: queryRet._id,\n\t\t\tresetDateReq,\n\t\t\tresetHash,\n\t\t\tname: queryRet.personalData?.name || ''\n\t\t}\n\t}\n\treturn ret\n}\n"]}
@@ -1,6 +1,11 @@
1
1
  import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
2
2
  export default async function removeResetReq(session, email) {
3
- return UserBase.updateOne({ 'login.email': email }, { $unset: { 'account.resetDateReq': '', 'account.email.hash': '' } }, { upsert: true })
3
+ // No { upsert: true }. An upsert on a clearing operation is backwards: when the email matched no
4
+ // document MongoDB did not no-op, it inserted one keyed by login.email — and updateOne skips
5
+ // validators, so that row bypassed every required field in the schema (login.password,
6
+ // account.email.valid, account.registrationDate). A no-op is the only correct answer to "clear the
7
+ // reset state of a user that does not exist".
8
+ return UserBase.updateOne({ 'login.email': email }, { $unset: { 'account.resetDateReq': '', 'account.resetHash': '' } })
4
9
  .session(session)
5
10
  .exec();
6
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"removeResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/removeResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,KAAa;IACjF,OAAO,QAAQ,CAAC,SAAS,CACxB,EAAE,aAAa,EAAE,KAAK,EAAE,EACxB,EAAE,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,EAAE,EACpE,EAAE,MAAM,EAAE,IAAI,EAAE,CAChB;SACC,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;AACT,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport default async function removeResetReq(session: ClientSession, email: string) {\n\treturn UserBase.updateOne(\n\t\t{ 'login.email': email },\n\t\t{ $unset: { 'account.resetDateReq': '', 'account.email.hash': '' } },\n\t\t{ upsert: true }\n\t)\n\t\t.session(session)\n\t\t.exec()\n}\n"]}
1
+ {"version":3,"file":"removeResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/removeResetReq.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,KAAa;IACjF,iGAAiG;IACjG,6FAA6F;IAC7F,uFAAuF;IACvF,mGAAmG;IACnG,8CAA8C;IAC9C,OAAO,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,EAAE,CAAC;SACtH,OAAO,CAAC,OAAO,CAAC;SAChB,IAAI,EAAE,CAAA;AACT,CAAC","sourcesContent":["import { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession } from 'mongoose'\n\nexport default async function removeResetReq(session: ClientSession, email: string) {\n\t// No { upsert: true }. An upsert on a clearing operation is backwards: when the email matched no\n\t// document MongoDB did not no-op, it inserted one keyed by login.email — and updateOne skips\n\t// validators, so that row bypassed every required field in the schema (login.password,\n\t// account.email.valid, account.registrationDate). A no-op is the only correct answer to \"clear the\n\t// reset state of a user that does not exist\".\n\treturn UserBase.updateOne({ 'login.email': email }, { $unset: { 'account.resetDateReq': '', 'account.resetHash': '' } })\n\t\t.session(session)\n\t\t.exec()\n}\n"]}
@@ -6,7 +6,10 @@ export const saveResetReq = async function (session, _id, now, hash) {
6
6
  await UserBase.updateOne({ _id }, {
7
7
  $set: {
8
8
  'account.resetDateReq': now,
9
- 'account.email.hash': hash
9
+ // account.resetHash, never account.email.hash: writing the verification slot here
10
+ // invalidated any pending activation or email-change link, and left a live reset
11
+ // token in the field those flows compare against.
12
+ 'account.resetHash': hash
10
13
  }
11
14
  }, { session, runValidators: true });
12
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"saveResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/saveResetReq.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,qDAAyC;AACtE,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,WAAW,OAAsB,EAAE,GAAmB,EAAE,GAAS,EAAE,IAAY;IAC/G,gDAAgD;IAChD,IAAI,CAAC;QACJ,MAAM,QAAQ,CAAC,SAAS,CACvB,EAAE,GAAG,EAAE,EACP;YACC,IAAI,EAAE;gBACL,sBAAsB,EAAE,GAAG;gBAC3B,oBAAoB,EAAE,IAAI;aAC1B;SACD,EACD,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAChC,CAAA;IACF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,kBAAkB,CAAC,CAAkB,CAAC,CAAA;IAC7C,CAAC;AACF,CAAC,CAAA","sourcesContent":["import { IMongoDBError } from '@lib/MongoDB/IMongoDBError.mjs'\nimport { throwMongoDBErrors } from '@lib/MongoDB/throwMongoErrors.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nexport const saveResetReq = async function (session: ClientSession, _id: Types.ObjectId, now: Date, hash: string) {\n\t// console.debug('imposto reset in coll Utenti')\n\ttry {\n\t\tawait UserBase.updateOne(\n\t\t\t{ _id },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\t'account.resetDateReq': now,\n\t\t\t\t\t'account.email.hash': hash\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ session, runValidators: true }\n\t\t)\n\t} catch (e) {\n\t\tthrow throwMongoDBErrors(e as IMongoDBError)\n\t}\n}\n"]}
1
+ {"version":3,"file":"saveResetReq.mjs","sourceRoot":"","sources":["../../../../../src/private/lib/access/db/saveResetReq.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,qDAAyC;AACtE,OAAO,EAAE,QAAQ,EAAE,wDAAoC;AAGvD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,WAAW,OAAsB,EAAE,GAAmB,EAAE,GAAS,EAAE,IAAY;IAC/G,gDAAgD;IAChD,IAAI,CAAC;QACJ,MAAM,QAAQ,CAAC,SAAS,CACvB,EAAE,GAAG,EAAE,EACP;YACC,IAAI,EAAE;gBACL,sBAAsB,EAAE,GAAG;gBAC3B,kFAAkF;gBAClF,iFAAiF;gBACjF,kDAAkD;gBAClD,mBAAmB,EAAE,IAAI;aACzB;SACD,EACD,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAChC,CAAA;IACF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,kBAAkB,CAAC,CAAkB,CAAC,CAAA;IAC7C,CAAC;AACF,CAAC,CAAA","sourcesContent":["import { IMongoDBError } from '@lib/MongoDB/IMongoDBError.mjs'\nimport { throwMongoDBErrors } from '@lib/MongoDB/throwMongoErrors.mjs'\nimport { UserBase } from '@models/MongoDB/UserBase.mjs'\nimport { ClientSession, Types } from 'mongoose'\n\nexport const saveResetReq = async function (session: ClientSession, _id: Types.ObjectId, now: Date, hash: string) {\n\t// console.debug('imposto reset in coll Utenti')\n\ttry {\n\t\tawait UserBase.updateOne(\n\t\t\t{ _id },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\t'account.resetDateReq': now,\n\t\t\t\t\t// account.resetHash, never account.email.hash: writing the verification slot here\n\t\t\t\t\t// invalidated any pending activation or email-change link, and left a live reset\n\t\t\t\t\t// token in the field those flows compare against.\n\t\t\t\t\t'account.resetHash': hash\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ session, runValidators: true }\n\t\t)\n\t} catch (e) {\n\t\tthrow throwMongoDBErrors(e as IMongoDBError)\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiumine/koa-utils",
3
- "version": "5.0.3",
3
+ "version": "5.1.1",
4
4
  "description": "Koa Utils",
5
5
  "type": "module",
6
6
  "repository": {