Skip to content

Instantly share code, notes, and snippets.

@jankuca
Created July 15, 2012 08:44
Show Gist options
  • Save jankuca/3115947 to your computer and use it in GitHub Desktop.
Save jankuca/3115947 to your computer and use it in GitHub Desktop.
var darkside = require('darkside');
var DashboardController = function (users) {
darkside.base(darkside.ViewController, this);
this.$users = users;
};
require('util').inherits(DashboardController, darkside.ViewController);
DashboardController.prototype.$deps = ['users'];
darkside.extend(DashboardController.prototype, {
init: function (done) {
this.bearcms_session_key = this.$request.cookies['bearcms_session_key'] || null;
this.bearcms_username= this.$request.cookies['bearcms_username'] || null;
if (this.bearcms_session_key == null || this.bearcms_username == null) {
return this.redirectTo('backend:sign:login');
}
this.view['bearcms_session_key'] = this.bearcms_session_key;
this.view['bearcms_username'] = this.bearcms_username;
done();
},
'index': function (params) {
this.$users.all(null, function (err, users) {
if (err) {
this.response.end(503);
} else {
this.view['users'] = users;
this.render();
}
}, this);
},
});
module.exports = DashboardController;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment