parent
1b74b21420
commit
bb24ed53a4
@ -1,6 +1,8 @@
|
|||||||
|
import * as argon2 from "argon2";
|
||||||
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||||
import crypto from "crypto";
|
import * as uuid from 'uuid';
|
||||||
import { StatsClient } from '../entities/StatsClient';
|
import { StatsClient } from '../entities/StatsClient';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This classed is used to create a new StatsClient entity from a json body (post request).
|
* This classed is used to create a new StatsClient entity from a json body (post request).
|
||||||
*/
|
*/
|
||||||
@ -22,11 +24,11 @@ export class CreateStatsClient {
|
|||||||
/**
|
/**
|
||||||
* Converts this to a StatsClient entity.
|
* Converts this to a StatsClient entity.
|
||||||
*/
|
*/
|
||||||
public toStatsClient(): StatsClient {
|
public async toStatsClient(): Promise<StatsClient> {
|
||||||
let newClient: StatsClient = new StatsClient();
|
let newClient: StatsClient = new StatsClient();
|
||||||
|
|
||||||
newClient.description = this.description;
|
newClient.description = this.description;
|
||||||
newClient.key = crypto.randomBytes(20).toString('hex');
|
newClient.key = await argon2.hash(uuid.v4());
|
||||||
if (this.enabled === undefined || this.enabled === null) { newClient.enabled = true; }
|
if (this.enabled === undefined || this.enabled === null) { newClient.enabled = true; }
|
||||||
else { newClient.enabled = this.enabled }
|
else { newClient.enabled = this.enabled }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user