fixed conflicts

v1.18.x
psychobunny 12 years ago
commit 877219cb58

@ -12,7 +12,7 @@ var socket,
socket = io.connect('http://' + config.socket.address + config.socket.port? ':' + config.socket.port : '');
socket.on('event:connect', function(data) {
console.log('connected to socket.io: ', data);
console.log('connected to nodebb socket: ', data);
});
socket.on('event:alert', function(data) {

@ -0,0 +1,18 @@
<h1>Account Settings</h1>
<div class="well">
<div class="alert" id="message" style="display:none">
<button type="button" class="close" data-dismiss="message">&times;</button>
<strong></strong>
<p></p>
</div>
<!-- <label for="email">Email Address</label><input type="text" placeholder="Enter Email Address" id="email" /><br />
<button class="btn btn-primary" id="reset" type="submit">Reset Password</button> -->
<p>
If you see this, you are logged in.
</p>
</div>
<script type="text/javascript">
(function() {
// ...
}());
</script>

@ -21,11 +21,11 @@ var config = require('../config.js'),
return global.socket.emit('user.login', {'status': 0, 'message': 'Incorrect username / password combination.'});
} else {
// Start, replace, or extend a session
RDB.get('uid:' + uid + ':session', function(session) {
RDB.get('session:' + user.sessionID, function(session) {
if (session !== user.sessionID) {
RDB.set('uid:' + uid + ':session', user.sessionID, 60*60*24*14); // Login valid for two weeks
RDB.set('session:' + user.sessionID, uid, 60*60*24*14); // Login valid for two weeks
} else {
RDB.expire('uid:' + uid + ':session', 60*60*24*14); // Defer expiration to two weeks from now
RDB.expire('session:' + user.sessionID, 60*60*24*14); // Defer expiration to two weeks from now
}
});
@ -103,6 +103,10 @@ var config = require('../config.js'),
RDB.get('email:' + email, callback)
};
User.get_uid_by_session = function(session, callback) {
RDB.get('session:' + session, callback);
};
User.reset = {
validate: function(code, callback) {
if (typeof callback !== 'function') callback = undefined;

@ -16,7 +16,7 @@ var express = require('express'),
}
function checkAuth(req, res, next) {
if (!req.session || !req.session.uid) {
if (!global.uid) {
res.send(403, 'You are not authorized to view this page');
} else {
next();
@ -27,13 +27,23 @@ var express = require('express'),
app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc)
app.use(express.bodyParser()); // Puts POST vars in request.body
app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
app.use(express.session({secret: 'nodebb-julian', key: 'express.sid'}));
app.use(express.session({secret: 'nodebb', key: 'express.sid'}));
app.use(function(req, res, next) {
global.modules.user.get_uid_by_session(req.sessionID, function(uid) {
if (uid) global.uid = uid;
next();
});
});
// Dunno wtf this does
// app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
// Useful if you want to use app.put and app.delete (instead of app.post all the time)
// app.use(express.methodOverride());
app.get('/', function(req, res) {
//global.modules.topics.get(function() {
// res.send(templates['header'] + templates['home'] + templates['footer']);
//})
res.send(templates['header'] + templates['home'] + templates['footer']);
});

@ -15,7 +15,7 @@ var SocketIO = require('socket.io').listen(global.server),
io.set('authorization', function(handshakeData, accept) {
if (handshakeData.headers.cookie) {
handshakeData.cookie = cookie.parse(handshakeData.headers.cookie);
handshakeData.sessionID = connect.utils.parseSignedCookie(handshakeData.cookie['express.sid'], 'nodebb-julian');
handshakeData.sessionID = connect.utils.parseSignedCookie(handshakeData.cookie['express.sid'], 'nodebb');
if (handshakeData.cookie['express.sid'] == handshakeData.sessionID) {
return accept('Cookie is invalid.', false);

Loading…
Cancel
Save