mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-08 02:15:02 -04:00
refactor(api/private/tokens): validate POST data with DTO
This adds a `AuthTokenCreateDto` which allows to fully validate incoming JSON data. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
fd3fde9cc8
commit
552cb05d92
3 changed files with 24 additions and 7 deletions
|
@ -4,9 +4,10 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsOptional, IsString } from 'class-validator';
|
||||
import { IsDate, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
import { TimestampMillis } from '../utils/timestamp';
|
||||
|
||||
export class AuthTokenDto extends BaseDto {
|
||||
@IsString()
|
||||
|
@ -33,3 +34,11 @@ export class AuthTokenWithSecretDto extends AuthTokenDto {
|
|||
@IsString()
|
||||
secret: string;
|
||||
}
|
||||
|
||||
export class AuthTokenCreateDto extends BaseDto {
|
||||
@IsString()
|
||||
label: string;
|
||||
|
||||
@IsNumber()
|
||||
validUntil: TimestampMillis;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue