Merge branch 'staging' into preprod
This commit is contained in:
commit
d83b9d6f2a
@ -67,6 +67,9 @@ export class BackendVariables {
|
|||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
public readonly PINATA_GATEWAY!: string;
|
public readonly PINATA_GATEWAY!: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
public readonly PINATA_GATEWAY_TOKEN!: string;
|
||||||
|
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
public readonly ACCESS_TOKEN_SECRET!: string;
|
public readonly ACCESS_TOKEN_SECRET!: string;
|
||||||
|
|
||||||
@ -150,6 +153,7 @@ export class BackendVariables {
|
|||||||
this.PINATA_API_KEY = process.env["PINATA_API_KEY"]!;
|
this.PINATA_API_KEY = process.env["PINATA_API_KEY"]!;
|
||||||
this.PINATA_API_SECRET = process.env["PINATA_API_SECRET"]!;
|
this.PINATA_API_SECRET = process.env["PINATA_API_SECRET"]!;
|
||||||
this.PINATA_GATEWAY = process.env["PINATA_GATEWAY"]!;
|
this.PINATA_GATEWAY = process.env["PINATA_GATEWAY"]!;
|
||||||
|
this.PINATA_GATEWAY_TOKEN = process.env["PINATA_GATEWAY_TOKEN"]!;
|
||||||
this.ACCESS_TOKEN_SECRET = process.env["ACCESS_TOKEN_SECRET"]!;
|
this.ACCESS_TOKEN_SECRET = process.env["ACCESS_TOKEN_SECRET"]!;
|
||||||
this.REFRESH_TOKEN_SECRET = process.env["REFRESH_TOKEN_SECRET"]!;
|
this.REFRESH_TOKEN_SECRET = process.env["REFRESH_TOKEN_SECRET"]!;
|
||||||
this.MAILCHIMP_API_KEY = process.env["MAILCHIMP_API_KEY"]!;
|
this.MAILCHIMP_API_KEY = process.env["MAILCHIMP_API_KEY"]!;
|
||||||
@ -170,8 +174,6 @@ export class BackendVariables {
|
|||||||
this.OVH_CONSUMER_KEY = process.env["OVH_CONSUMER_KEY"]!;
|
this.OVH_CONSUMER_KEY = process.env["OVH_CONSUMER_KEY"]!;
|
||||||
this.OVH_SMS_SERVICE_NAME = process.env["OVH_SMS_SERVICE_NAME"]!;
|
this.OVH_SMS_SERVICE_NAME = process.env["OVH_SMS_SERVICE_NAME"]!;
|
||||||
this.SMS_FACTOR_TOKEN = process.env["SMS_FACTOR_TOKEN"]!;
|
this.SMS_FACTOR_TOKEN = process.env["SMS_FACTOR_TOKEN"]!;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public async validate(groups?: string[]) {
|
public async validate(groups?: string[]) {
|
||||||
const validationOptions = groups ? { groups } : undefined;
|
const validationOptions = groups ? { groups } : undefined;
|
||||||
@ -179,7 +181,7 @@ export class BackendVariables {
|
|||||||
try {
|
try {
|
||||||
await validateOrReject(this, validationOptions);
|
await validateOrReject(this, validationOptions);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (process.env["ENV"] === "dev" || process.env["ENV"] === 'stg') {
|
if (process.env["ENV"] === "dev" || process.env["ENV"] === "stg") {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
throw new Error("Some env variables are required!");
|
throw new Error("Some env variables are required!");
|
||||||
|
@ -59,7 +59,7 @@ export default class FilesService extends BaseService {
|
|||||||
public async download(uid: string) {
|
public async download(uid: string) {
|
||||||
const file = await this.filesRepository.findOneByUid(uid);
|
const file = await this.filesRepository.findOneByUid(uid);
|
||||||
if (!file?.key) return null;
|
if (!file?.key) return null;
|
||||||
const fileResult = await fetch(file.file_path);
|
const fileResult = await fetch(file.file_path.concat("?pinataGatewayToken=").concat(this.variables.PINATA_GATEWAY_TOKEN));
|
||||||
const fileArrayBuffer = await fileResult.arrayBuffer();
|
const fileArrayBuffer = await fileResult.arrayBuffer();
|
||||||
return { file: file, buffer: await this.cryptoService.decrypt(Buffer.from(fileArrayBuffer), file.key) };
|
return { file: file, buffer: await this.cryptoService.decrypt(Buffer.from(fileArrayBuffer), file.key) };
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// import { BackendVariables } from "@Common/config/variables/Variables";
|
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||||
import { Customers, Prisma, TotpCodes } from "@prisma/client";
|
import { Customers, Prisma, TotpCodes } from "@prisma/client";
|
||||||
import CustomersRepository from "@Repositories/CustomersRepository";
|
import CustomersRepository from "@Repositories/CustomersRepository";
|
||||||
import TotpCodesRepository from "@Repositories/TotpCodesRepository";
|
import TotpCodesRepository from "@Repositories/TotpCodesRepository";
|
||||||
@ -57,7 +57,7 @@ export default class CustomersService extends BaseService {
|
|||||||
private customerRepository: CustomersRepository,
|
private customerRepository: CustomersRepository,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private totpCodesRepository: TotpCodesRepository,
|
private totpCodesRepository: TotpCodesRepository,
|
||||||
// private variables: BackendVariables,
|
private variables: BackendVariables,
|
||||||
private ovhService: OvhService,
|
private ovhService: OvhService,
|
||||||
private smsFactorService: SmsFactorService,
|
private smsFactorService: SmsFactorService,
|
||||||
) {
|
) {
|
||||||
@ -110,8 +110,7 @@ export default class CustomersService extends BaseService {
|
|||||||
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), reason);
|
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), reason);
|
||||||
if (!totpCode) return null;
|
if (!totpCode) return null;
|
||||||
// 5: Send the SMS code to the customer
|
// 5: Send the SMS code to the customer
|
||||||
// if(this.variables.ENV !== 'dev')
|
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
|
||||||
await this.sendSmsCodeToCustomer(totpPin, customer);
|
|
||||||
return {
|
return {
|
||||||
customer,
|
customer,
|
||||||
totpCode: TotpCodesResource.hydrate<TotpCodesResource>({
|
totpCode: TotpCodesResource.hydrate<TotpCodesResource>({
|
||||||
@ -163,8 +162,7 @@ export default class CustomersService extends BaseService {
|
|||||||
await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60000), TotpCodesReasons.RESET_PASSWORD);
|
await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60000), TotpCodesReasons.RESET_PASSWORD);
|
||||||
|
|
||||||
// 5: Send the SMS code to the customer
|
// 5: Send the SMS code to the customer
|
||||||
// if(this.variables.ENV !== 'dev')
|
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
|
||||||
await this.sendSmsCodeToCustomer(totpPin, customer);
|
|
||||||
return customer;
|
return customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,8 +292,7 @@ export default class CustomersService extends BaseService {
|
|||||||
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), totpCodeToResend.reason!, true);
|
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), totpCodeToResend.reason!, true);
|
||||||
|
|
||||||
// 7: Send the SMS code to the customer
|
// 7: Send the SMS code to the customer
|
||||||
// if(this.variables.ENV !== 'dev')
|
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
|
||||||
await this.sendSmsCodeToCustomer(totpPin, customer);
|
|
||||||
return { customer, totpCode };
|
return { customer, totpCode };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user