aktueller Stand
This commit is contained in:
22
server.js
22
server.js
@@ -105,7 +105,9 @@ async function restoreSessionsFromDisk() {
|
||||
};
|
||||
const isAdminUser = isAdmin(profile);
|
||||
let config = readConfig(profile.id);
|
||||
const stores = await foodsharingClient.fetchStores(auth.cookieHeader, profile.id);
|
||||
const stores = await foodsharingClient.fetchStores(auth.cookieHeader, profile.id, {
|
||||
delayBetweenRequestsMs: schedulerSettings.storePickupCheckDelayMs
|
||||
});
|
||||
const { merged, changed } = mergeStoresIntoConfig(config, stores);
|
||||
if (changed) {
|
||||
config = merged;
|
||||
@@ -169,9 +171,12 @@ app.post('/api/auth/login', async (req, res) => {
|
||||
email: auth.profile.email || email
|
||||
};
|
||||
const isAdminUser = isAdmin(profile);
|
||||
const settings = adminConfig.readSettings();
|
||||
|
||||
let config = readConfig(profile.id);
|
||||
const stores = await foodsharingClient.fetchStores(auth.cookieHeader, profile.id);
|
||||
const stores = await foodsharingClient.fetchStores(auth.cookieHeader, profile.id, {
|
||||
delayBetweenRequestsMs: settings.storePickupCheckDelayMs
|
||||
});
|
||||
const { merged, changed } = mergeStoresIntoConfig(config, stores);
|
||||
if (changed) {
|
||||
config = merged;
|
||||
@@ -193,7 +198,6 @@ app.post('/api/auth/login', async (req, res) => {
|
||||
}, existingToken, ONE_YEAR_MS);
|
||||
|
||||
credentialStore.save(profile.id, { email, password, token: session.id });
|
||||
const settings = adminConfig.readSettings();
|
||||
scheduleConfig(session.id, config, settings);
|
||||
|
||||
return res.json({
|
||||
@@ -217,7 +221,10 @@ app.post('/api/auth/logout', requireAuth, (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/auth/session', requireAuth, async (req, res) => {
|
||||
const stores = await foodsharingClient.fetchStores(req.session.cookieHeader, req.session.profile.id);
|
||||
const settings = adminConfig.readSettings();
|
||||
const stores = await foodsharingClient.fetchStores(req.session.cookieHeader, req.session.profile.id, {
|
||||
delayBetweenRequestsMs: settings.storePickupCheckDelayMs
|
||||
});
|
||||
let config = readConfig(req.session.profile.id);
|
||||
const { merged, changed } = mergeStoresIntoConfig(config, stores);
|
||||
if (changed) {
|
||||
@@ -228,7 +235,7 @@ app.get('/api/auth/session', requireAuth, async (req, res) => {
|
||||
profile: req.session.profile,
|
||||
stores,
|
||||
isAdmin: !!req.session.isAdmin,
|
||||
adminSettings: req.session.isAdmin ? adminConfig.readSettings() : undefined
|
||||
adminSettings: req.session.isAdmin ? settings : undefined
|
||||
});
|
||||
});
|
||||
|
||||
@@ -254,7 +261,10 @@ app.post('/api/config', requireAuth, (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/stores', requireAuth, async (req, res) => {
|
||||
const stores = await foodsharingClient.fetchStores(req.session.cookieHeader, req.session.profile.id);
|
||||
const settings = adminConfig.readSettings();
|
||||
const stores = await foodsharingClient.fetchStores(req.session.cookieHeader, req.session.profile.id, {
|
||||
delayBetweenRequestsMs: settings.storePickupCheckDelayMs
|
||||
});
|
||||
let config = readConfig(req.session.profile.id);
|
||||
const { merged, changed } = mergeStoresIntoConfig(config, stores);
|
||||
if (changed) {
|
||||
|
||||
Reference in New Issue
Block a user