Skip to content

Commit

Permalink
Add call to fetchAssessmentsByUser() to RSCRegister endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Grayson committed Apr 11, 2024
1 parent facac52 commit 1ca6067
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
IsEnum,
IsInt,
IsIn,
IsNumber,
IsObject,
IsPositive,
ValidateNested,
IsUUID
IsPositive
} from 'class-validator';
import { User, connectToDatabase, Role, Organization } from '../models';
import {
connectToDatabase,
Organization,
Role,
User,
UserType
} from '../models';
import {
validateBody,
wrapHandler,
Expand All @@ -25,7 +27,6 @@ import {
sendRegistrationApprovedEmail,
sendRegistrationDeniedEmail
} from './helpers';
import { UserType } from '../models/user';
import {
getUserId,
canAccessUser,
Expand All @@ -34,9 +35,7 @@ import {
isOrgAdmin,
isGlobalWriteAdmin
} from './auth';
import { Type, plainToClass } from 'class-transformer';
import { IsNull } from 'typeorm';
import { create } from './organizations';
import { fetchAssessmentsByUser } from '../tasks/rscSync';

class UserSearch {
@IsInt()
Expand Down Expand Up @@ -949,8 +948,10 @@ export const RSCRegister = wrapHandler(async (event) => {
};
// Create if user does not exist
} else {
user = await User.create(newRSCUser);
user = User.create(newRSCUser);
await User.save(user);
// Fetch RSC assessments for user
await fetchAssessmentsByUser(user.email);
// Send email notification
if (process.env.IS_LOCAL!) {
console.log('Cannot send invite email while running on local.');
Expand Down

0 comments on commit 1ca6067

Please sign in to comment.