mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-09-12 05:16:42 -05:00
processLoginRequest() now uses cache and async fs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const fs = require('fs-extra');
|
||||
const express = require('express');
|
||||
const util = require('../../../util');
|
||||
const database = require('../../../database');
|
||||
@@ -55,12 +55,21 @@ async function processLoginRequest(request) {
|
||||
|
||||
const cryptoPath = `${__dirname}/../../../../certs/nex/${service_name}`;
|
||||
|
||||
const publicKey = fs.readFileSync(`${cryptoPath}/public.pem`);
|
||||
const hmacSecret = fs.readFileSync(`${cryptoPath}/secret.key`);
|
||||
let publicKey = cache.getNEXPublicKey(service_name);
|
||||
if (publicKey === null) {
|
||||
publicKey = await fs.readFile(`${cryptoPath}/public.pem`);
|
||||
await cache.setNEXPublicKey(service_name, publicKey);
|
||||
}
|
||||
|
||||
let secretKey = cache.getNEXSecretKey(service_name);
|
||||
if (secretKey === null) {
|
||||
secretKey = await fs.readFile(`${cryptoPath}/secret.key`);
|
||||
await cache.setNEXSecretKey(service_name, secretKey);
|
||||
}
|
||||
|
||||
const cryptoOptions = {
|
||||
public_key: publicKey,
|
||||
hmac_secret: hmacSecret
|
||||
hmac_secret: secretKey
|
||||
};
|
||||
|
||||
const tokenOptions = {
|
||||
|
||||
Reference in New Issue
Block a user