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
1 change: 0 additions & 1 deletion backend/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@

// 5. Send an email to the user with a link containing the token
const resetLink = `${
process.env.CKBOARD_SERVER_ADDRESS!.startsWith('http') ? '' : 'https://'

Check warning on line 110 in backend/src/api/auth.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

Forbidden non-null assertion
}${process.env.CKBOARD_SERVER_ADDRESS!}/reset-password?token=${resetToken}`;

Check warning on line 111 in backend/src/api/auth.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

Forbidden non-null assertion

try {
await generateEmail(email, 'Password Reset Request', resetLink);
Expand Down Expand Up @@ -242,7 +242,6 @@
});

router.get('/generate-api-key/:id', isAuthenticated, async (req, res) => {
console.log('here');
const userId = req.params.id;

// 1. Find the user by the id
Expand All @@ -262,12 +261,12 @@
const apiKeyPrefix = apiKey.substring(0, 5);

// 5. Update the user's api key and prefix
const newUser = await dalUser.update(userId, {

Check warning on line 264 in backend/src/api/auth.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

'newUser' is assigned a value but never used
apiKey: hashedApiKey,
apiKeyPrefix: apiKeyPrefix,
});

const updatedUser = await dalUser.findByUserID(userId);

Check warning on line 269 in backend/src/api/auth.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

'updatedUser' is assigned a value but never used

res.status(200).json(apiKey);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/components/toolbar/toolbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ <h3 style="margin: 8px 0">{{ user.username }}</h3>
</div>
<mat-divider></mat-divider>
<button
*ngIf="apiKeyGenerated === false"
*ngIf="apiKeyGenerated === false && user.role === Role.TEACHER"
mat-menu-item
(click)="generateApiKey()"
>
<mat-icon>api</mat-icon>
<span>Generate an API Key</span>
</button>
<button
*ngIf="apiKeyGenerated === true"
*ngIf="apiKeyGenerated === true && user.role === Role.TEACHER"
mat-menu-item
(click)="regenerateApiKey()"
>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/components/toolbar/toolbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthUser } from 'src/app/models/user';
import { AuthUser, Role } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';
import { Board, BoardScope } from 'src/app/models/board'; // Import Board and BoardScope
import { Project } from 'src/app/models/project'; // Import Project
Expand Down Expand Up @@ -33,6 +33,8 @@ export class ToolbarComponent implements OnInit {

hovering = false;

Role: typeof Role = Role;

constructor(
private userService: UserService,
private snackbarService: SnackbarService,
Expand Down
Loading