@@ -36,7 +36,7 @@ import { UploadSongResponseDto } from '@shared/validation/song/dto/UploadSongRes
36
36
import type { Response } from 'express' ;
37
37
38
38
import { FileService } from '@server/file/file.service' ;
39
- import { GetRequestToken } from '@server/GetRequestUser' ;
39
+ import { GetRequestToken , validateUser } from '@server/GetRequestUser' ;
40
40
import { UserDocument } from '@server/user/entity/user.entity' ;
41
41
42
42
import { SongService } from './song.service' ;
@@ -80,6 +80,7 @@ export class SongController {
80
80
@Param ( 'id' ) id : string ,
81
81
@GetRequestToken ( ) user : UserDocument | null ,
82
82
) : Promise < SongViewDto > {
83
+ user = validateUser ( user ) ;
83
84
return await this . songService . getSong ( id , user ) ;
84
85
}
85
86
@@ -91,6 +92,7 @@ export class SongController {
91
92
@Param ( 'id' ) id : string ,
92
93
@GetRequestToken ( ) user : UserDocument | null ,
93
94
) : Promise < UploadSongDto > {
95
+ user = validateUser ( user ) ;
94
96
return await this . songService . getSongEdit ( id , user ) ;
95
97
}
96
98
@@ -107,9 +109,9 @@ export class SongController {
107
109
@Req ( ) req : RawBodyRequest < Request > ,
108
110
@GetRequestToken ( ) user : UserDocument | null ,
109
111
) : Promise < UploadSongResponseDto > {
112
+ user = validateUser ( user ) ;
110
113
//TODO: Fix this weird type casting and raw body access
111
114
const body = req . body as unknown as UploadSongDto ;
112
-
113
115
return await this . songService . patchSong ( id , body , user ) ;
114
116
}
115
117
@@ -128,6 +130,7 @@ export class SongController {
128
130
'Access-Control-Expose-Headers' : 'Content-Disposition' ,
129
131
} ) ;
130
132
133
+ user = validateUser ( user ) ;
131
134
const url = await this . songService . getSongDownloadUrl ( id , user , src , false ) ;
132
135
res . redirect ( HttpStatus . FOUND , url ) ;
133
136
}
@@ -139,6 +142,8 @@ export class SongController {
139
142
@GetRequestToken ( ) user : UserDocument | null ,
140
143
@Headers ( 'src' ) src : string ,
141
144
) : Promise < string > {
145
+ user = validateUser ( user ) ;
146
+
142
147
if ( src != 'downloadButton' ) {
143
148
throw new UnauthorizedException ( 'Invalid source' ) ;
144
149
}
@@ -161,6 +166,7 @@ export class SongController {
161
166
@Param ( 'id' ) id : string ,
162
167
@GetRequestToken ( ) user : UserDocument | null ,
163
168
) : Promise < void > {
169
+ user = validateUser ( user ) ;
164
170
await this . songService . deleteSong ( id , user ) ;
165
171
}
166
172
@@ -181,6 +187,7 @@ export class SongController {
181
187
@Body ( ) body : UploadSongDto ,
182
188
@GetRequestToken ( ) user : UserDocument | null ,
183
189
) : Promise < UploadSongResponseDto > {
190
+ user = validateUser ( user ) ;
184
191
return await this . songService . uploadSong ( { body, file, user } ) ;
185
192
}
186
193
}
0 commit comments