Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added DataModel(March6th2025).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export class AuthController {
return await this.authService.setNewPassword(newPassword, session, username, email);
}

@Post('update-profile')
async updateProfile(
@Body('username') username: string,
@Body('displayName') displayName : string
): Promise<{message: string}> {
await this.authService.updateProfile(username,displayName)
return { message: 'Profile has been updated' };

}
@Post('update-profile')
async updateProfile(
@Body('username') username: string,
@Body('email') email: string,
@Body('position_or_role') position_or_role: string
): Promise<{ message: string }> {
await this.authService.updateProfile(username, email, position_or_role);
return { message: 'Profile has been updated' };
}
}
39 changes: 19 additions & 20 deletions backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,25 @@ export class AuthService {
}
}

async updateProfile(
username: string,
displayName : string,
) {
async updateProfile(username: string, email: string, position_or_role: string) {
const tableName = process.env.DYNAMODB_USER_TABLE_NAME || 'TABLE_FAILURE';

const params = {
TableName: tableName,
Key: { userId: username },
// Update both fields in one go:
UpdateExpression: 'SET email = :email, position_or_role = :position_or_role',
ExpressionAttributeValues: {
':email': email,
':position_or_role': position_or_role,
},
// Optional: return the newly updated item if you want to use it
// ReturnValues: 'ALL_NEW',
};

try {
const tableName = process.env.DYNAMODB_USER_TABLE_NAME || 'TABLE_FAILURE';

const params = {
TableName: tableName,
Key: { userId: username },
UpdateExpression: 'set displayName = :displayName',
ExpressionAttributeValues: {
':displayName': displayName
},
};

await this.dynamoDb.update(params).promise();

this.logger.log(
`User ${username} updated user profile.`,
);
await this.dynamoDb.update(params).promise();
this.logger.log(`User ${username} updated user profile.`);
} catch (error: unknown) {
if (error instanceof Error) {
this.logger.error('Updating the profile failed', error.stack);
Expand All @@ -321,4 +319,5 @@ export class AuthService {
throw new Error('An unknown error occurred');
}
}

}
2 changes: 1 addition & 1 deletion backend/src/grant/grant.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Get, Param, Put, Body, Patch } from '@nestjs/common';
import { GrantService } from './grant.service';
import {Grant} from "./grant.model";
import { Grant } from '../../../middle-layer/types/Grant';

@Controller('grant')
export class GrantController {
Expand Down
19 changes: 0 additions & 19 deletions backend/src/grant/grant.model.ts

This file was deleted.

2 changes: 1 addition & 1 deletion backend/src/grant/grant.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable,Logger } from '@nestjs/common';
import AWS from 'aws-sdk';
import { Grant } from './grant.model'
import { Grant } from '../../../middle-layer/types/Grant';

@Injectable()
export class GrantService {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/notifications/notifcation.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import * as AWS from 'aws-sdk';
import { Notification } from './notification.model';
import { Notification } from '../../../middle-layer/types/Notification';

@Injectable()
export class NotificationService {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/notifications/notification.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Post, Body, Get, Query, Param } from '@nestjs/common';
import { NotificationService } from './notifcation.service';
import { Notification } from './notification.model';
import { Notification } from '../../../middle-layer/types/Notification';


@Controller('notifications')
Expand Down
6 changes: 0 additions & 6 deletions backend/src/notifications/notification.model.ts

This file was deleted.

3 changes: 3 additions & 0 deletions backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Injectable } from '@nestjs/common';
import AWS from 'aws-sdk'

/**
* File could use safer 'User' typing after grabbing users, verifying type after the scan.
*/
@Injectable()
export class UserService {
private dynamoDb = new AWS.DynamoDB.DocumentClient();
Expand Down
6 changes: 4 additions & 2 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Future optimization should only include backend files, this includes all repos right now
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"rootDir": "../",
"module": "commonjs",
"target": "es2017",
"experimentalDecorators": true,
Expand All @@ -11,7 +12,8 @@
"skipLibCheck": true
},
"include": [
"src/**/*"
"src/**/*",
"../middle-layer/**/*"
],
"exclude": [
"node_modules",
Expand Down
Binary file added frontend/assets/images/boston_snow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading