mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-04-12 15:40:30 +08:00
chore: Small refactor
This commit is contained in:
parent
f89a885540
commit
bbd4353d0f
@ -21,12 +21,12 @@ import createSignInCallback from './createSignInCallback.js';
|
||||
|
||||
function createCallbacks({ authConfig, logger, plugins }) {
|
||||
const callbacks = {
|
||||
session: createSessionCallback({ authConfig, plugins }),
|
||||
session: createSessionCallback({ authConfig, logger, plugins }),
|
||||
};
|
||||
const jwt = createJWTCallback({ authConfig, logger, plugins });
|
||||
if (jwt) callbacks.jwt = jwt;
|
||||
|
||||
const redirect = createRedirectCallback({ authConfig, plugins });
|
||||
const redirect = createRedirectCallback({ authConfig, logger, plugins });
|
||||
if (redirect) callbacks.redirect = redirect;
|
||||
|
||||
const signIn = createSignInCallback({ authConfig, plugins });
|
||||
|
@ -45,11 +45,11 @@ function getNextAuthConfig({ authJson, logger, plugins, secrets }) {
|
||||
throw new Error(operatorErrors[0]);
|
||||
}
|
||||
|
||||
nextAuthConfig.adapter = createAdapter({ authConfig, plugins });
|
||||
nextAuthConfig.adapter = createAdapter({ authConfig, logger, plugins });
|
||||
nextAuthConfig.callbacks = createCallbacks({ authConfig, logger, plugins });
|
||||
nextAuthConfig.events = createEvents({ authConfig, logger, plugins });
|
||||
nextAuthConfig.logger = createLogger({ logger });
|
||||
nextAuthConfig.providers = createProviders({ authConfig, plugins });
|
||||
nextAuthConfig.providers = createProviders({ authConfig, logger, plugins });
|
||||
nextAuthConfig.debug = authConfig.debug ?? logger?.isLevelEnabled('debug') === true;
|
||||
nextAuthConfig.pages = authConfig.authPages;
|
||||
nextAuthConfig.session = authConfig.session;
|
||||
|
@ -55,7 +55,7 @@ async function sha1(filePath) {
|
||||
return crypto
|
||||
.createHash('sha1')
|
||||
.update(content || '')
|
||||
.digest('hex');
|
||||
.digest('base64');
|
||||
}
|
||||
|
||||
async function nextBuildWatcher(context) {
|
||||
|
@ -22,16 +22,18 @@ const config = {
|
||||
},
|
||||
};
|
||||
|
||||
let license;
|
||||
|
||||
async function validateLicense() {
|
||||
if (global.license) {
|
||||
if (license) {
|
||||
// Check cached license every 24 hours
|
||||
if (global.license?.timestamp.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
|
||||
return global.license;
|
||||
if (license?.timestamp.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
|
||||
return license;
|
||||
}
|
||||
}
|
||||
|
||||
global.license = await keygenValidateLicense({ config: config['dev'] });
|
||||
return global.license;
|
||||
license = await keygenValidateLicense({ config: config['dev'] });
|
||||
return license;
|
||||
}
|
||||
|
||||
export default validateLicense;
|
||||
|
@ -19,7 +19,7 @@ import crypto from 'crypto';
|
||||
|
||||
function getCacheKey(fileData, filePath, options) {
|
||||
const optionsString = typeof options === 'string' ? options : JSON.stringify(options);
|
||||
return crypto.createHash('sha1').update(fileData).update(optionsString).digest('hex');
|
||||
return crypto.createHash('sha1').update(fileData).update(optionsString).digest('base64');
|
||||
}
|
||||
|
||||
function process(sourceText) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user