feat: add jwt auth guard and profile endpoint
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
ValidationArguments,
|
||||
ValidatorConstraint,
|
||||
ValidatorConstraintInterface,
|
||||
} from 'class-validator';
|
||||
|
||||
@ValidatorConstraint({ name: 'MatchFields', async: false })
|
||||
export class MatchFieldsConstraint implements ValidatorConstraintInterface {
|
||||
validate(value: any, args: ValidationArguments): boolean {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const [property] = args.constraints;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
const relatedValue = (args.object as any)[property];
|
||||
|
||||
return value === relatedValue;
|
||||
}
|
||||
|
||||
defaultMessage(args: ValidationArguments): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const [property] = args.constraints;
|
||||
return `${args.property} must match ${property}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user