mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fixed conflicts
This commit is contained in:
@@ -12,7 +12,7 @@ var socket,
|
|||||||
socket = io.connect('http://' + config.socket.address + config.socket.port? ':' + config.socket.port : '');
|
socket = io.connect('http://' + config.socket.address + config.socket.port? ':' + config.socket.port : '');
|
||||||
|
|
||||||
socket.on('event:connect', function(data) {
|
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) {
|
socket.on('event:alert', function(data) {
|
||||||
|
|||||||
18
public/templates/account_settings.tpl
Normal file
18
public/templates/account_settings.tpl
Normal file
@@ -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">×</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>
|
||||||
10
src/user.js
10
src/user.js
@@ -21,11 +21,11 @@ var config = require('../config.js'),
|
|||||||
return global.socket.emit('user.login', {'status': 0, 'message': 'Incorrect username / password combination.'});
|
return global.socket.emit('user.login', {'status': 0, 'message': 'Incorrect username / password combination.'});
|
||||||
} else {
|
} else {
|
||||||
// Start, replace, or extend a session
|
// Start, replace, or extend a session
|
||||||
RDB.get('uid:' + uid + ':session', function(session) {
|
RDB.get('session:' + user.sessionID, function(session) {
|
||||||
if (session !== user.sessionID) {
|
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 {
|
} 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)
|
RDB.get('email:' + email, callback)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
User.get_uid_by_session = function(session, callback) {
|
||||||
|
RDB.get('session:' + session, callback);
|
||||||
|
};
|
||||||
|
|
||||||
User.reset = {
|
User.reset = {
|
||||||
validate: function(code, callback) {
|
validate: function(code, callback) {
|
||||||
if (typeof callback !== 'function') callback = undefined;
|
if (typeof callback !== 'function') callback = undefined;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var express = require('express'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkAuth(req, res, next) {
|
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');
|
res.send(403, 'You are not authorized to view this page');
|
||||||
} else {
|
} else {
|
||||||
next();
|
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.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.bodyParser()); // Puts POST vars in request.body
|
||||||
app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
|
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
|
// Dunno wtf this does
|
||||||
// app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
|
// 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)
|
// Useful if you want to use app.put and app.delete (instead of app.post all the time)
|
||||||
// app.use(express.methodOverride());
|
// app.use(express.methodOverride());
|
||||||
|
|
||||||
app.get('/', function(req, res) {
|
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']);
|
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) {
|
io.set('authorization', function(handshakeData, accept) {
|
||||||
if (handshakeData.headers.cookie) {
|
if (handshakeData.headers.cookie) {
|
||||||
handshakeData.cookie = cookie.parse(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) {
|
if (handshakeData.cookie['express.sid'] == handshakeData.sessionID) {
|
||||||
return accept('Cookie is invalid.', false);
|
return accept('Cookie is invalid.', false);
|
||||||
|
|||||||
Reference in New Issue
Block a user