Skip to content

Commit 5227e27

Browse files
committed
refactor: remove user suspension check (already checked in auth middlewares)
1 parent ac5270f commit 5227e27

1 file changed

Lines changed: 0 additions & 19 deletions

File tree

backend/src/entities/cedar-authorization/cedar-permissions.service.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
2727
) {}
2828

2929
async getUserConnectionAccessLevel(cognitoUserName: string, connectionId: string): Promise<AccessLevelEnum> {
30-
await this.assertUserNotSuspended(cognitoUserName);
3130
const ctx = await this.loadContext(connectionId, cognitoUserName);
3231
if (!ctx) return AccessLevelEnum.none;
3332

@@ -60,7 +59,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
6059
}
6160

6261
async checkUserConnectionRead(cognitoUserName: string, connectionId: string): Promise<boolean> {
63-
await this.assertUserNotSuspended(cognitoUserName);
6462
const ctx = await this.loadContext(connectionId, cognitoUserName);
6563
if (!ctx) return false;
6664

@@ -86,7 +84,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
8684
}
8785

8886
async checkUserConnectionEdit(cognitoUserName: string, connectionId: string): Promise<boolean> {
89-
await this.assertUserNotSuspended(cognitoUserName);
9087
const ctx = await this.loadContext(connectionId, cognitoUserName);
9188
if (!ctx) return false;
9289

@@ -102,7 +99,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
10299
}
103100

104101
async getGroupAccessLevel(cognitoUserName: string, groupId: string): Promise<AccessLevelEnum> {
105-
await this.assertUserNotSuspended(cognitoUserName);
106102
const connectionId = await this.getConnectionId(groupId);
107103
const ctx = await this.loadContext(connectionId, cognitoUserName);
108104
if (!ctx) return AccessLevelEnum.none;
@@ -152,7 +148,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
152148
tableName: string,
153149
_masterPwd: string,
154150
): Promise<ITablePermissionData> {
155-
await this.assertUserNotSuspended(cognitoUserName);
156151
const ctx = await this.loadContext(connectionId, cognitoUserName);
157152
if (!ctx) {
158153
return { tableName, accessLevel: { visibility: false, readonly: false, add: false, delete: false, edit: false } };
@@ -166,7 +161,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
166161
connectionId: string,
167162
tableNames: Array<string>,
168163
): Promise<Array<ITablePermissionData>> {
169-
await this.assertUserNotSuspended(cognitoUserName);
170164
const ctx = await this.loadContext(connectionId, cognitoUserName);
171165
if (!ctx) return [];
172166

@@ -186,7 +180,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
186180
tableName: string,
187181
_masterPwd: string,
188182
): Promise<boolean> {
189-
await this.assertUserNotSuspended(cognitoUserName);
190183
const ctx = await this.loadContext(connectionId, cognitoUserName);
191184
if (!ctx) return false;
192185

@@ -207,7 +200,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
207200
tableName: string,
208201
_masterPwd: string,
209202
): Promise<boolean> {
210-
await this.assertUserNotSuspended(cognitoUserName);
211203
const ctx = await this.loadContext(connectionId, cognitoUserName);
212204
if (!ctx) return false;
213205

@@ -228,7 +220,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
228220
tableName: string,
229221
_masterPwd: string,
230222
): Promise<boolean> {
231-
await this.assertUserNotSuspended(cognitoUserName);
232223
const ctx = await this.loadContext(connectionId, cognitoUserName);
233224
if (!ctx) return false;
234225

@@ -249,7 +240,6 @@ export class CedarPermissionsService implements IUserAccessRepository {
249240
tableName: string,
250241
_masterPwd: string,
251242
): Promise<boolean> {
252-
await this.assertUserNotSuspended(cognitoUserName);
253243
const ctx = await this.loadContext(connectionId, cognitoUserName);
254244
if (!ctx) return false;
255245

@@ -383,13 +373,4 @@ export class CedarPermissionsService implements IUserAccessRepository {
383373
return { userGroups, policies };
384374
}
385375

386-
private async assertUserNotSuspended(userId: string): Promise<void> {
387-
const user = await this.globalDbContext.userRepository.findOne({
388-
where: { id: userId },
389-
select: ['id', 'suspended'],
390-
});
391-
if (user?.suspended) {
392-
throw new HttpException({ message: Messages.ACCOUNT_SUSPENDED }, HttpStatus.FORBIDDEN);
393-
}
394-
}
395376
}

0 commit comments

Comments
 (0)