How to use the keystone.get function in keystone

To help you get started, we’ve selected a few keystone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skagitpublishing / connextCMS / routes / api / imageupload.js View on Github external
//Ensure the user has a valid CSRF token
	//if (!security.csrf.validate(req)) {
	//	return res.apiError(403, 'invalid csrf');
	//}
  
  //Ensure the user making the request is a Keystone Admin
  //var isAdmin = req.user.get('isAdmin');
  //if(!isAdmin) {
  //  return res.apiError(403, 'Not allowed to access this API. Not Keystone Admin.');
  //}
  
  //Since it's possible to spoof the Keystone Admin setting in the current version of the User model,
  //This is a check to make sure the user is a ConnexstCMS Admin
  var admins = keystone.get('admins');
  var superusers = keystone.get('superusers');
  var userId = req.user.get('id');
  if((admins.indexOf(userId) == -1) && (superusers.indexOf(userId) == -1)) {
    return res.apiError(403, 'Not allowed to access this API. Not ConnextCMS Admin');
  }
  
  ImgData.model.findById(req.params.id).exec(function(err, item) {

    if (err) return res.apiError('database error', err);
    if (!item) return res.apiError('not found');

    var data = (req.method == 'POST') ? req.body : req.query;

    item.getUpdateHandler(req).process(data, function(err) {

      if (err) return res.apiError('create error', err);
github skagitpublishing / connextCMS / routes / views / edituser.js View on Github external
exports = module.exports = function(req, res) {

        var view = new keystone.View(req, res);
        var locals = res.locals;

        locals.user = req.user;
        locals.user.password = "";

        locals.superusers = keystone.get('superusers');
  
        // Set locals
        locals.section = 'edituser';

        // Render the view
        view.render('edituser');

};
github keycircle / keyuxt / server / index.js View on Github external
brand: 'Keystone Boilerplate',
  static: 'public',
  logger: ':method :url :status :response-time ms - :res[content-length]',
  'auto update': false,
  session: true,
  auth: true,
  'user model': 'User',
  compress: true,
  headless: false // true to disable admin
})

keystone.import('../server/models')

keystone.set('locals', {
  _,
  env: keystone.get('env'),
  utils: keystone.utils,
  editable: keystone.content.editable
})

keystone.set('routes', server)

keystone.set('nav', {
  posts: ['posts', 'post-categories'],
  enquiries: 'enquiries',
  users: 'users'
})

keystone.start()
github shlomiassaf / resty-stone / example / keystone.js View on Github external
'user model': 'User',
	'cookie secret': 'Y43`>-nb]).#N>)65(HY:TT])f?/:%=W~c"eTHY[`S.CarRf]9VaOw^$aMM[EtGz'

});

// Load your project's Models

keystone.import('models');

// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js

keystone.set('locals', {
	_: require('underscore'),
	env: keystone.get('env'),
	utils: keystone.utils,
	editable: keystone.content.editable
});

// Load your project's Routes

keystone.set('routes', require('./routes'));

// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.

keystone.set('email locals', {
	logo_src: '/images/logo-email.gif',
	logo_width: 194,
	logo_height: 76,
	theme: {
github keystonejs / keystone-test-project / express.js View on Github external
var app = new express();

keystone.init(config.options);
keystone.import('models');
keystone.set('locals', config.locals);
keystone.set('routes', require('./routes'));
keystone.set('nav', config.nav);

keystone.initDatabaseConfig();
keystone.initExpressSession();

app.use(compression());
app.use('/keystone', keystone.Admin.Server.createStaticRouter(keystone));
app.use(express.static('public'));

app.use(keystone.get('session options').cookieParser);
app.use(keystone.expressSession);
app.use(keystone.session.persist);
app.use(require('connect-flash')());

app.use(morgan('tiny'));
app.use('/keystone', keystone.Admin.Server.createDynamicRouter(keystone));

app.use(function (req, res) {
	res.redirect('/keystone');
});

keystone.openDatabaseConnection(function () {
	var server = app.listen(process.env.PORT || 3001, function () {
		console.log('-------------------------------');
		console.log('Express server ready on port %d', server.address().port);
		console.log('-------------------------------');