Skip to content

Commit

Permalink
Merge branch 'master' into elemental-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Aug 13, 2015
2 parents 8d2c3e3 + d998f65 commit 9426394
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions admin/api/session/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function get (req, res) {
return res.json({ user: req.user });
}

module.exports = get;
17 changes: 6 additions & 11 deletions lib/core/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@ function routes(app) {
// Cache compiled view templates if we are in Production mode
this.set('view cache', this.get('env') === 'production');

// Session API
// TODO: this should respect keystone auth options
app.get('/keystone/api/session', require('../../admin/api/session/get'));
app.post('/keystone/api/session/signin', require('../../admin/api/session/signin'));
app.post('/keystone/api/session/signout', require('../../admin/api/session/signout'));

// Bind auth middleware (generic or custom) to /keystone* routes, allowing
// access to the generic signin page if generic auth is used

if (this.get('auth') === true) {
debug('setting up auth');

if (!this.get('signout url')) {
this.set('signout url', '/keystone/signout');
}
if (!this.get('signin url')) {
this.set('signin url', '/keystone/signin');
}

if (!this.nativeApp || !this.get('session')) {
app.all('/keystone*', this.session.persist);
}

app.all('/keystone/signin', require('../../admin/routes/views/signin'));
app.all('/keystone/signout', require('../../admin/routes/views/signout'));
app.all('/keystone*', this.session.keystoneAuth);

} else if ('function' === typeof this.get('auth')) {
debug('setting up auth');
app.all('/keystone*', this.get('auth'));
}

Expand Down Expand Up @@ -107,10 +106,6 @@ function routes(app) {
next();
});

// Session API
app.post('/keystone/api/session/signin', require('../../admin/api/session/signin'));
app.post('/keystone/api/session/signout', require('../../admin/api/session/signout'));

// Generic Lists API
app.all('/keystone/api/:list/:action(autocomplete|order|create|fetch)', initList(), require('../../admin/api/list'));
app.post('/keystone/api/:list/delete', initList(), require('../../admin/api/list/delete'));
Expand Down

0 comments on commit 9426394

Please sign in to comment.