fixes miscellaneous bugs while initializing with no localization, globals, custom css
This commit is contained in:
@@ -53,7 +53,6 @@ const CreateFirstUser = (props) => {
|
||||
type: 'password',
|
||||
required: true,
|
||||
},
|
||||
...userConfig.fields,
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
0
src/client/scss/overrides.scss
Normal file
0
src/client/scss/overrides.scss
Normal file
@@ -9,9 +9,12 @@ const buildCollectionSchema = (collection, config, schemaOptions = {}) => {
|
||||
|
||||
schema.plugin(paginate)
|
||||
.plugin(buildQueryPlugin)
|
||||
.plugin(localizationPlugin, config.localization)
|
||||
.plugin(autopopulate);
|
||||
|
||||
if (config.localization) {
|
||||
schema.plugin(localizationPlugin, config.localization);
|
||||
}
|
||||
|
||||
return schema;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ const mongooseHidden = require('mongoose-hidden')({
|
||||
const passport = require('passport');
|
||||
const passportLocalMongoose = require('passport-local-mongoose');
|
||||
const LocalStrategy = require('passport-local').Strategy;
|
||||
const AnonymousStrategy = require('passport-anonymous');
|
||||
const jwtStrategy = require('../auth/strategies/jwt');
|
||||
const apiKeyStrategy = require('../auth/strategies/apiKey');
|
||||
const collectionRoutes = require('./routes');
|
||||
@@ -133,7 +132,6 @@ function registerCollections() {
|
||||
passport.use(`${AuthCollection.config.slug}-jwt`, jwtStrategy(this.config, AuthCollection));
|
||||
passport.serializeUser(AuthCollection.Model.serializeUser());
|
||||
passport.deserializeUser(AuthCollection.Model.deserializeUser());
|
||||
passport.use(new AnonymousStrategy.Strategy());
|
||||
|
||||
this.router.use(authRoutes(AuthCollection, this.config, this.sendEmail));
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const express = require('express');
|
||||
const passport = require('passport');
|
||||
const AnonymousStrategy = require('passport-anonymous');
|
||||
const compression = require('compression');
|
||||
const bodyParser = require('body-parser');
|
||||
const methodOverride = require('method-override');
|
||||
@@ -10,6 +11,8 @@ const authenticate = require('./authenticate');
|
||||
const identifyAPI = require('./identifyAPI');
|
||||
|
||||
const middleware = (config) => {
|
||||
passport.use(new AnonymousStrategy.Strategy());
|
||||
|
||||
return [
|
||||
passport.initialize(),
|
||||
passport.session(),
|
||||
|
||||
@@ -6,46 +6,48 @@ const {
|
||||
} = require('./resolvers');
|
||||
|
||||
function registerGlobals() {
|
||||
Object.keys(this.globals.config).forEach((slug) => {
|
||||
const global = this.globals.config[slug];
|
||||
const {
|
||||
label,
|
||||
fields,
|
||||
} = global;
|
||||
if (this.config.globals) {
|
||||
Object.keys(this.globals.config).forEach((slug) => {
|
||||
const global = this.globals.config[slug];
|
||||
const {
|
||||
label,
|
||||
fields,
|
||||
} = global;
|
||||
|
||||
const formattedLabel = formatName(label);
|
||||
const formattedLabel = formatName(label);
|
||||
|
||||
global.graphQL = {};
|
||||
global.graphQL = {};
|
||||
|
||||
global.graphQL.type = this.buildObjectType(
|
||||
formattedLabel,
|
||||
fields,
|
||||
formattedLabel,
|
||||
);
|
||||
global.graphQL.type = this.buildObjectType(
|
||||
formattedLabel,
|
||||
fields,
|
||||
formattedLabel,
|
||||
);
|
||||
|
||||
global.graphQL.mutationInputType = new GraphQLNonNull(this.buildMutationInputType(
|
||||
formattedLabel,
|
||||
fields,
|
||||
formattedLabel,
|
||||
));
|
||||
global.graphQL.mutationInputType = new GraphQLNonNull(this.buildMutationInputType(
|
||||
formattedLabel,
|
||||
fields,
|
||||
formattedLabel,
|
||||
));
|
||||
|
||||
this.Query.fields[formattedLabel] = {
|
||||
type: global.graphQL.type,
|
||||
args: {
|
||||
locale: { type: this.types.localeInputType },
|
||||
fallbackLocale: { type: this.types.fallbackLocaleInputType },
|
||||
},
|
||||
resolve: findOne(this.globals.Model, global),
|
||||
};
|
||||
this.Query.fields[formattedLabel] = {
|
||||
type: global.graphQL.type,
|
||||
args: {
|
||||
locale: { type: this.types.localeInputType },
|
||||
fallbackLocale: { type: this.types.fallbackLocaleInputType },
|
||||
},
|
||||
resolve: findOne(this.globals.Model, global),
|
||||
};
|
||||
|
||||
this.Mutation.fields[`update${formattedLabel}`] = {
|
||||
type: global.graphQL.type,
|
||||
args: {
|
||||
data: { type: global.graphQL.mutationInputType },
|
||||
},
|
||||
resolve: update(this.globals.Model, global),
|
||||
};
|
||||
});
|
||||
this.Mutation.fields[`update${formattedLabel}`] = {
|
||||
type: global.graphQL.type,
|
||||
args: {
|
||||
data: { type: global.graphQL.mutationInputType },
|
||||
},
|
||||
resolve: update(this.globals.Model, global),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = registerGlobals;
|
||||
|
||||
@@ -3,9 +3,9 @@ const sanitize = require('./sanitize');
|
||||
const routes = require('./routes');
|
||||
|
||||
function initGlobals() {
|
||||
this.config.globals = sanitize(this.config.globals);
|
||||
|
||||
if (this.config.globals) {
|
||||
this.config.globals = sanitize(this.config.globals);
|
||||
|
||||
this.globals = {
|
||||
Model: buildModel(this.config),
|
||||
config: this.config.globals,
|
||||
|
||||
@@ -20,10 +20,13 @@ class GraphQL {
|
||||
this.types = {
|
||||
blockTypes: {},
|
||||
blockInputTypes: {},
|
||||
localeInputType: buildLocaleInputType(this.config.localization),
|
||||
fallbackLocaleInputType: buildFallbackLocaleInputType(this.config.localization),
|
||||
};
|
||||
|
||||
if (this.config.localization) {
|
||||
this.types.localeInputType = buildLocaleInputType(this.config.localization);
|
||||
this.types.fallbackLocaleInputType = buildFallbackLocaleInputType(this.config.localization);
|
||||
}
|
||||
|
||||
this.Query = {
|
||||
name: 'Query',
|
||||
fields: {},
|
||||
|
||||
@@ -23,6 +23,9 @@ class Payload {
|
||||
const config = getConfig(options);
|
||||
|
||||
this.config = sanitizeConfig(config);
|
||||
|
||||
if (typeof this.config.paths === 'undefined') this.config.paths = {};
|
||||
|
||||
this.config.paths.publicConfig = options.config.public;
|
||||
|
||||
this.express = options.express;
|
||||
|
||||
@@ -6,26 +6,28 @@
|
||||
*/
|
||||
module.exports = function localizationMiddleware(localization) {
|
||||
const middleware = (req, res, next) => {
|
||||
const validLocales = [...localization.locales, 'all'];
|
||||
const validFallbackLocales = [...localization.locales, 'null'];
|
||||
if (localization) {
|
||||
const validLocales = [...localization.locales, 'all'];
|
||||
const validFallbackLocales = [...localization.locales, 'null'];
|
||||
|
||||
let requestedLocale = req.query.locale || localization.defaultLocale;
|
||||
let requestedFallbackLocale = req.query['fallback-locale'] || localization.defaultLocale;
|
||||
let requestedLocale = req.query.locale || localization.defaultLocale;
|
||||
let requestedFallbackLocale = req.query['fallback-locale'] || localization.defaultLocale;
|
||||
|
||||
if (req.body) {
|
||||
if (req.body.locale) requestedLocale = req.body.locale;
|
||||
if (req.body['fallback-locale']) requestedFallbackLocale = req.body['fallback-locale'];
|
||||
}
|
||||
if (req.body) {
|
||||
if (req.body.locale) requestedLocale = req.body.locale;
|
||||
if (req.body['fallback-locale']) requestedFallbackLocale = req.body['fallback-locale'];
|
||||
}
|
||||
|
||||
if (requestedFallbackLocale === 'none') requestedFallbackLocale = 'null';
|
||||
if (requestedLocale === '*' || requestedLocale === 'all') requestedLocale = 'all';
|
||||
if (requestedFallbackLocale === 'none') requestedFallbackLocale = 'null';
|
||||
if (requestedLocale === '*' || requestedLocale === 'all') requestedLocale = 'all';
|
||||
|
||||
if (validLocales.find(locale => locale === requestedLocale)) {
|
||||
req.locale = requestedLocale;
|
||||
}
|
||||
if (validLocales.find(locale => locale === requestedLocale)) {
|
||||
req.locale = requestedLocale;
|
||||
}
|
||||
|
||||
if (validFallbackLocales.find(locale => locale === requestedFallbackLocale)) {
|
||||
req.fallbackLocale = requestedFallbackLocale;
|
||||
if (validFallbackLocales.find(locale => locale === requestedFallbackLocale)) {
|
||||
req.fallbackLocale = requestedFallbackLocale;
|
||||
}
|
||||
}
|
||||
|
||||
return next();
|
||||
|
||||
@@ -7,6 +7,8 @@ const sanitizeConfig = (config) => {
|
||||
|
||||
if (!sanitizedConfig.cookiePrefix) sanitizedConfig.cookiePrefix = 'payload';
|
||||
|
||||
if (!sanitizedConfig.globals) sanitizedConfig.globals = [];
|
||||
|
||||
if (!sanitizedConfig.admin.user) {
|
||||
sanitizedConfig.admin.user = config.admin.user || 'users';
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ const webpack = require('webpack');
|
||||
const getStyleLoaders = require('./getStyleLoaders');
|
||||
const secureConfig = require('../utilities/secureConfig');
|
||||
|
||||
const dependency = 'fuck';
|
||||
|
||||
module.exports = (config) => {
|
||||
return {
|
||||
const webpackConfig = {
|
||||
entry: {
|
||||
main: [
|
||||
path.resolve(__dirname, '../../node_modules/webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000'),
|
||||
@@ -118,8 +116,15 @@ module.exports = (config) => {
|
||||
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
|
||||
alias: {
|
||||
'payload/config': config.paths.publicConfig,
|
||||
'payload-scss-overrides': config.paths.scss,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (config.paths.scss) {
|
||||
webpackConfig.resolve.alias['payload-scss-overrides'] = config.paths.scss;
|
||||
} else {
|
||||
webpackConfig.resolve.alias['payload-scss-overrides'] = path.resolve(__dirname, '../client/scss/overrides.scss');
|
||||
}
|
||||
|
||||
return webpackConfig;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user