• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 14841635864

05 May 2025 04:47PM UTC coverage: 44.381% (-0.08%) from 44.464%
14841635864

push

github

web-flow
Merge pull request #12058 from hicommonwealth/tim/user-ban-hammer

1666 of 4133 branches covered (40.31%)

Branch coverage included in aggregate %.

3 of 17 new or added lines in 3 files covered. (17.65%)

1 existing line in 1 file now uncovered.

3034 of 6457 relevant lines covered (46.99%)

38.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/model/src/aggregates/super-admin/SetUserTier.command.ts
1
import { Command, InvalidInput } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { UserTierMap } from '@hicommonwealth/shared';
4
import { models } from '../../database';
5
import { isSuperAdmin } from '../../middleware';
6

7
export function SetUserTier(): Command<typeof schemas.SetUserTier> {
NEW
8
  return {
×
9
    ...schemas.SetUserTier,
10
    auth: [isSuperAdmin],
11
    body: async ({ actor, payload }) => {
NEW
12
      const { user_id, tier } = payload;
×
13

NEW
14
      if (
×
15
        user_id === actor.user.id &&
×
16
        (tier === UserTierMap.BannedUser || tier === UserTierMap.IncompleteUser)
17
      ) {
NEW
18
        throw new InvalidInput('Cannot ban yourself');
×
19
      }
20

NEW
21
      const user = await models.User.findByPk(user_id);
×
NEW
22
      if (!user) throw new InvalidInput('User not found');
×
23

NEW
24
      if (user.tier === tier) {
×
NEW
25
        return { success: true };
×
26
      }
27

NEW
28
      user.tier = tier;
×
NEW
29
      await user.save();
×
30

NEW
31
      return { success: true };
×
32
    },
33
  };
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc