mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
auth: Integrate suggestions by @davidmehren
Add number type alias TimestampMillis Remove solved ToDos Change AuthToken and AuthTokenDto to use Date Rename authService unit tests Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
e6dc8c7678
commit
a8b46923fd
7 changed files with 149 additions and 93 deletions
|
@ -17,6 +17,7 @@ import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|||
import { AuthTokenDto } from '../../../auth/auth-token.dto';
|
||||
import { AuthTokenWithSecretDto } from '../../../auth/auth-token-with-secret.dto';
|
||||
import { AuthService } from '../../../auth/auth.service';
|
||||
import { TimestampMillis } from '../../../utils/timestamp';
|
||||
|
||||
@Controller('tokens')
|
||||
export class TokensController {
|
||||
|
@ -38,10 +39,10 @@ export class TokensController {
|
|||
@Post()
|
||||
async postTokenRequest(
|
||||
@Body('label') label: string,
|
||||
@Body('until') until: number,
|
||||
@Body('validUntil') validUntil: TimestampMillis,
|
||||
): Promise<AuthTokenWithSecretDto> {
|
||||
// ToDo: Get real userName
|
||||
return this.authService.createTokenForUser('hardcoded', label, until);
|
||||
return this.authService.createTokenForUser('hardcoded', label, validUntil);
|
||||
}
|
||||
|
||||
@Delete('/:keyId')
|
||||
|
|
|
@ -48,7 +48,6 @@ export class MediaController {
|
|||
@UploadedFile() file: MulterFile,
|
||||
@Headers('HedgeDoc-Note') noteId: string,
|
||||
) {
|
||||
//TODO: Get user from request
|
||||
const username = req.user.userName;
|
||||
this.logger.debug(
|
||||
`Recieved filename '${file.originalname}' for note '${noteId}' from user '${username}'`,
|
||||
|
@ -74,7 +73,6 @@ export class MediaController {
|
|||
@UseGuards(TokenAuthGuard)
|
||||
@Delete(':filename')
|
||||
async deleteMedia(@Request() req, @Param('filename') filename: string) {
|
||||
//TODO: Get user from request
|
||||
const username = req.user.userName;
|
||||
try {
|
||||
await this.mediaService.deleteFile(filename, username);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue