Commit e9dcbbc9 authored by Mariana Carmin's avatar Mariana Carmin

Abre a tela inicial para a busca

parent b8a0ad24
......@@ -28,7 +28,7 @@
<input type="search" placeholder="O que você procura?" name="query"
class="search-bar two-thirds" autofocus required>
<!-- Value do submit foi retirado daqui: http://fortawesome.github.io/Font-Awesome/cheatsheet/-->
<input type="submit" class="icon-button dark" value="&#xf002;">
<input type="submit" class="icon-button dark" value="&#xf002;" >
</form>
</section>
<p><a id="upload" class="upload-link" href="/upload">Faça o upload de uma prova ou trabalho!</a></p>
......
<html>
<% include partials/head %>
<body>
<% include partials/basic-header %>
<p> <%= b %> </p>
<% include partials/footer %>
</body>
</html>
\ No newline at end of file
File added
File added
File added
File added
......@@ -23,6 +23,7 @@ var materias = require('./routes/admin/materias')
var professores = require('./routes/admin/professores')
var usuarios = require('./routes/admin/usuarios')
var api = require('./routes/api/api')
var usuariosRest = require('./routes/api/usuarios')
var materiasRest = require('./routes/api/materias')
......
......@@ -86,6 +86,40 @@ passport.deserializeUser(function(id, done) {
})
})
passport.use('local-search', new LocalStrategy({
passReqToCallback: true
}, function(req, username, password, done) {
process.nextTick(function() {
var nome = req.body.search
Usuario.findOne({'username': username}, function(err, user) {
if(err) {
return done(err)
}
if(user) {
return done(null, false, req.flash('signupMessage', 'Este usuario já existe'))
} else {
var usuario = new Usuario()
console.log(req.body)
usuario.nome = req.body.nome
usuario.email = req.body.email
usuario.username = username
usuario.password = password
usuario.save(function(err) {
if(err) {
console.log('Internal error: %s', err.message)
return done(null, false, req.flash('signupMessage', 'Erro ao salvar o usuário: ' + err.message))
}
email.sendVerifyToUser(usuario, req.protocol, req.get('host'))
return done(null, usuario)
})
}
})
})
}))
passport.use('local-signup', new LocalStrategy({
passReqToCallback: true
}, function(req, username, password, done) {
......
......@@ -61,6 +61,16 @@ router.post('/login', passport.authenticate('local-login', {
return res.redirect('/')
})
router.get('/search', function(req, res) {
res.render('search', {message: req.flash('loginMessage')})
})
router.post('/search', function(req, res) {
var bus = req.body.query
console.log(bus);
res.render('search', {b: bus})
})
router.get('/logout', function(req, res) {
req.logout()
res.redirect('/')
......
mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment