mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 11:37:02 -04:00
Get user from Session instead of hardcoded value
Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
parent
263de45748
commit
ad190fcf22
7 changed files with 92 additions and 67 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
InternalServerErrorException,
|
||||
Post,
|
||||
UploadedFile,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
|
@ -20,6 +21,7 @@ import {
|
|||
MediaBackendError,
|
||||
NotInDBError,
|
||||
} from '../../../errors/errors';
|
||||
import { SessionGuard } from '../../../identity/session.guard';
|
||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
import { MediaUploadUrlDto } from '../../../media/media-upload-url.dto';
|
||||
import { MediaService } from '../../../media/media.service';
|
||||
|
@ -28,7 +30,9 @@ import { Note } from '../../../notes/note.entity';
|
|||
import { NotesService } from '../../../notes/notes.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { UsersService } from '../../../users/users.service';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(SessionGuard)
|
||||
@Controller('media')
|
||||
export class MediaController {
|
||||
constructor(
|
||||
|
@ -46,9 +50,8 @@ export class MediaController {
|
|||
async uploadMedia(
|
||||
@UploadedFile() file: MulterFile,
|
||||
@Headers('HedgeDoc-Note') noteId: string,
|
||||
@RequestUser() user: User,
|
||||
): Promise<MediaUploadUrlDto> {
|
||||
// ToDo: Get real userName
|
||||
const user: User = await this.userService.getUserByUsername('hardcoded');
|
||||
try {
|
||||
// TODO: Move getting the Note object into a decorator
|
||||
const note: Note = await this.noteService.getNoteByIdOrAlias(noteId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue