Skip to content

Commit

Permalink
fixed auth
Browse files Browse the repository at this point in the history
  • Loading branch information
santiago committed Sep 3, 2012
1 parent 051a43f commit 53f8302
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 195 deletions.
170 changes: 0 additions & 170 deletions :q

This file was deleted.

2 changes: 0 additions & 2 deletions domain/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function Service(app) {
var Evaluacion = app.db.model('Evaluacion');

function getCreativos(req, res, next) {
console.log("************");
console.log(req.query);
var query = (function() {
if (req.params.id) {
return { _id: req.params.id }
Expand Down
1 change: 1 addition & 0 deletions domain/Evaluaciones.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function Service(app) {
console.log(req.params.taller_id);
Sesion.findById(req.params.taller_id, function(err, r) {
req.sesion = r;
console.log(r);
next();
});
}
Expand Down
5 changes: 2 additions & 3 deletions models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ var Creativo = new Schema({
email : { type: String },
telefono : { type: String },
direccion : { type: String },
titulo : { type: String },
ids_talleres : { type: Array },
titulo : { type: String }
});
mongoose.model('Creativo', Creativo);

var Evaluacion = new Schema({
participante_id : { type: String }
, creativo_id : { type: String }
, creativo_cedula : { type: String }
, fecha : { type: Date }
, taller_id : { type: String, index: true }
, habilidades : { type: Array }
Expand Down
30 changes: 10 additions & 20 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ everyauth.debug = true;
//Intialize authentication with username/password
require('./lib/Auth')(app)

everyauth.password
.findUserById( function (id, callback) {
console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%***");
Usuario.findById(id, callback);
});
everyauth.everymodule.findUserById(function (id, callback) {
app.db.model('Usuario').findById(id, callback);
});


// Configuration
Expand All @@ -47,9 +45,12 @@ app.configure(function(){
}));
this.use(express.favicon(__dirname + '/public/favicon.ico', { maxAge: 2592000000}));
this.use(express.static(__dirname + '/public'));

this.use(everyauth.middleware());

// Keep this as last one
this.use(this.router);

this.use(function(req, res, next){
res.render('error', { status: 404, error_text: '404 Pagina no encontrada en el sistema', url: req.url });
});
Expand Down Expand Up @@ -82,28 +83,17 @@ app.get('/login', function(req, res){
});

app.get('*', function(req, res, next) {
if (!req.session.auth) {
var auth = req.session.auth;

if (!auth || !auth.loggedIn) {
res.redirect('/login');
} else {
if (typeof req.session.creativo_id == 'undefined') {
req.session.creativo_id = '71381688';
}
next();
}
});

app.get('/', function(req, res) {
if (req.session.user) {
console.log('Session found, redirecting..................');
res.redirect('/equipamientos');
} else {
console.log('No session found, rendering index..................');
res.render('index', {
locals:{
articulo: 'None'
}
});
}
res.redirect('/equipamientos');
});

// Initialize Domain
Expand Down

0 comments on commit 53f8302

Please sign in to comment.