parent
1b74b21420
commit
bb24ed53a4
|
@ -1,6 +1,8 @@
|
|||
import * as argon2 from "argon2";
|
||||
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||
import crypto from "crypto";
|
||||
import * as uuid from 'uuid';
|
||||
import { StatsClient } from '../entities/StatsClient';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public toStatsClient(): StatsClient {
|
||||
public async toStatsClient(): Promise<StatsClient> {
|
||||
let newClient: StatsClient = new StatsClient();
|
||||
|
||||
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; }
|
||||
else { newClient.enabled = this.enabled }
|
||||
|
||||
|
|
Loading…
Reference in New Issue