@social-mail/social-mail-web-server 1.4.807 → 1.4.809

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.4.807",
3
+ "version": "1.4.809",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -51,7 +51,6 @@ export default class UserAuthFactor {
51
51
  isdCode: string;
52
52
 
53
53
  @Column({ dataType: "Boolean"})
54
- @ReadOnlyJsonProperty
55
54
  verified: boolean;
56
55
 
57
56
  @Column({})
@@ -139,7 +139,7 @@ export default class LoginSessionEvents extends EntityEvents<LoginSession> {
139
139
  const otpIn = await this.db.userAuthFactors.where(user, (p) => (x) => x.userID === p.userID && x.method === "otp-in")
140
140
  .toArray();
141
141
 
142
- if (otpIn) {
142
+ if (otpIn.length) {
143
143
  const code = entity.smsToken = AppStringHelper.last(DateTime.now.msSinceEpoch.toString(), 6);
144
144
  const idsCodes = otpIn.map((x) => x.isdCode.startsWith("+") ? x.isdCode : "+" + x.isdCode );
145
145
  entity.smsConfig = await ServiceProvider.resolve(this, IncomingSmsService).prepareCode(code, ... idsCodes);
@@ -85,7 +85,12 @@ export default class UserAuthFactorEvents extends AuthenticatedEvents<UserAuthFa
85
85
 
86
86
  async beforeUpdate(entity: UserAuthFactor, entry: ChangeEntry<UserAuthFactor>) {
87
87
  if(entry.isModified("verified")) {
88
- throw new EntityAccessError(`Cannot modify verified`);
88
+ if (!this.sessionUser.isAdmin) {
89
+ throw new EntityAccessError(`Cannot modify verified`);
90
+ }
91
+ if(entity.verified) {
92
+ return;
93
+ }
89
94
  }
90
95
  if (entity.method !== "totp") {
91
96
  throw new EntityAccessError(`Cannot modify Auth Factor.`);