Implemented registration key generation

ref #112
This commit is contained in:
2021-01-21 17:48:13 +01:00
parent d490247d1e
commit ad446500f9
3 changed files with 54 additions and 3 deletions

View File

@@ -1,8 +1,13 @@
import {
IsArray,
IsBase64,
IsBoolean,
IsObject,
IsOptional
IsOptional,
IsString
} from "class-validator";
import { Address } from '../entities/Address';
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
@@ -27,6 +32,22 @@ export class ResponseRunnerOrganisation extends ResponseRunnerGroup {
@IsArray()
teams: RunnerTeam[];
/**
* The organisation's registration key.
* If registration is disabled this is null.
*/
@IsString()
@IsOptional()
@IsBase64()
registrationKey?: string;
/**
* Is registration enabled for the organisation?
*/
@IsOptional()
@IsBoolean()
registrtionEnabled?: boolean = true;
/**
* Creates a ResponseRunnerOrganisation object from a runnerOrganisation.
* @param org The runnerOrganisation the response shall be build for.
@@ -35,5 +56,7 @@ export class ResponseRunnerOrganisation extends ResponseRunnerGroup {
super(org);
this.address = org.address;
this.teams = org.teams;
if (!org.key) { this.registrtionEnabled = false; }
else { this.registrationKey = Buffer.from(org.key).toString('base64'); }
}
}