Skip to content

Commit

Permalink
Merge branch 'master' into fix/add-merch-photo-table-name-to-list
Browse files Browse the repository at this point in the history
  • Loading branch information
dowhep authored Feb 29, 2024
2 parents 4cd2556 + fa75324 commit f095a1c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/controllers/AttendanceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class AttendanceController {
return { error: null, attendances };
}

@UseBefore(UserAuthentication)
@Get('/user/:uuid')
async getAttendancesForUser(@Params() params: UuidParam,
@AuthenticatedUser() currentUser: UserModel): Promise<GetAttendancesForEventResponse> {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"moment-timezone": "^0.5.34",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"obscenity": "^0.2.0",
"pg": "^8.6.0",
"reflect-metadata": "^0.1.13",
"routing-controllers": "^0.9.0",
Expand Down
14 changes: 14 additions & 0 deletions services/UserAccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { EntityManager } from 'typeorm';
import * as moment from 'moment';
import * as faker from 'faker';
import { UserAccessUpdates } from 'api/validators/AdminControllerRequests';
import {
RegExpMatcher,
englishDataset,
englishRecommendedTransformers,
} from 'obscenity';
import Repositories, { TransactionsManager } from '../repositories';
import {
Uuid,
Expand All @@ -23,8 +28,14 @@ import { UserModel } from '../models/UserModel';
export default class UserAccountService {
private transactions: TransactionsManager;

private matcher: RegExpMatcher;

constructor(@InjectManager() entityManager: EntityManager) {
this.transactions = new TransactionsManager(entityManager);
this.matcher = new RegExpMatcher({
...englishDataset.build(),
...englishRecommendedTransformers,
});
}

public async findByUuid(uuid: Uuid): Promise<UserModel> {
Expand Down Expand Up @@ -104,6 +115,9 @@ export default class UserAccountService {
}
changes.hash = await UserRepository.generateHash(newPassword);
}
if (this.matcher.hasMatch(userPatches.handle)) {
throw new ForbiddenError('Please remove profanity from handle.');
}
return this.transactions.readWrite(async (txn) => {
if (userPatches.handle) {
const userRepository = Repositories.user(txn);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4342,6 +4342,11 @@ object.values@^1.1.5:
define-properties "^1.1.3"
es-abstract "^1.19.1"

obscenity@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/obscenity/-/obscenity-0.2.0.tgz#5a234c7af0aaebcd58fc762b29d2852104350fa2"
integrity sha512-eYe8r9hqJk5dEMZkLtWlGlwGxKYO6xA/yEOzd8MGSG3vzn8hAgo6MUZ9dirA3kPAfy/1d1jEOkCUpIU1nGI1EQ==

on-finished@^2.3.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f"
Expand Down

0 comments on commit f095a1c

Please sign in to comment.