Merge branch 'master' of https://bitbucket.org/cliffbreak/shakes-fidget
This commit is contained in:
commit
744e421c70
2 changed files with 16 additions and 27 deletions
37
index.js
37
index.js
|
@ -1,28 +1,17 @@
|
||||||
var app = require('express')(),
|
var app = require('express')(),
|
||||||
session = require('express-session'),
|
session = require('express-session'),
|
||||||
http = require('http').Server(app),
|
http = require('http').Server(app),
|
||||||
|
bodyParser = require('body-parser'),
|
||||||
request = require('request'),
|
request = require('request'),
|
||||||
exphbs = require('express-handlebars')
|
exphbs = require('express-handlebars')
|
||||||
|
|
||||||
app.engine('.hbs', exphbs({defaultLayout: 'single', extname: '.hbs'}))
|
app.engine('.hbs', exphbs({defaultLayout: 'single', extname: '.hbs'}))
|
||||||
app.set('view engine', '.hbs')
|
app.set('view engine', '.hbs')
|
||||||
|
|
||||||
// function checkAuth (req, res, next) {
|
|
||||||
// console.log(req.session);
|
|
||||||
|
|
||||||
// console.log('checkAuth ' + req.url);
|
|
||||||
|
|
||||||
// // don't serve /secure to those not logged in
|
app.use(session({ resave: true, saveUninitialized: false, secret: '62gzrhufijw' }))
|
||||||
// // you should add to this list, for each and every secure url
|
app.use(bodyParser.json())
|
||||||
// // if (req.url === '/' && (!req.session || !req.session.authenticated)) {
|
app.use(bodyParser.urlencoded({extended: true}))
|
||||||
// // res.render('unauthorised', { status: 403 });
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
// next()
|
|
||||||
// }
|
|
||||||
|
|
||||||
app.use(session({ secret: 'example' }))
|
|
||||||
// app.use(checkAuth)
|
|
||||||
|
|
||||||
|
|
||||||
var url = 'http://192.168.178.109:1024/'
|
var url = 'http://192.168.178.109:1024/'
|
||||||
|
@ -37,8 +26,8 @@ app.get('/', function(req, res){
|
||||||
url: url,
|
url: url,
|
||||||
json: true,
|
json: true,
|
||||||
auth: {
|
auth: {
|
||||||
user: 'Simon',
|
user: req.session.name,
|
||||||
pass: 'password'
|
pass: req.session.pass
|
||||||
}
|
}
|
||||||
}, function(error, response, body){
|
}, function(error, response, body){
|
||||||
var data = []
|
var data = []
|
||||||
|
@ -63,14 +52,16 @@ app.get('/assets/*', function(req, res){
|
||||||
})
|
})
|
||||||
|
|
||||||
app.post('/',function(req,res){
|
app.post('/',function(req,res){
|
||||||
console.log(req);
|
if(
|
||||||
|
req.body.name === 'Simon' && req.body.pass === 'password' ||
|
||||||
if(req.body.name === 'Admin' && req.body.pass === '1234'){
|
req.body.name === 'USER2' && req.body.pass === 'rfcgvhbßä06'
|
||||||
|
){
|
||||||
req.session.name = req.body.name
|
req.session.name = req.body.name
|
||||||
res.end('success')
|
req.session.pass = req.body.pass
|
||||||
|
res.end('true')
|
||||||
} else {
|
} else {
|
||||||
res.end('denied')
|
res.end()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
app.listen(8080)
|
app.listen(8080)
|
||||||
|
|
|
@ -12,10 +12,8 @@ $(document).ready(function(){
|
||||||
* Perform some validation here.
|
* Perform some validation here.
|
||||||
*/
|
*/
|
||||||
$.post(window.location.href, {name:name,pass:pass}, function(data){
|
$.post(window.location.href, {name:name,pass:pass}, function(data){
|
||||||
if(data==='success')
|
if(data === 'true')
|
||||||
{
|
window.location.href= '/';
|
||||||
window.location.href="/";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue