mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-16 17:01:39 +00:00
Added signing into different users
This commit is contained in:
parent
58a87b3a3d
commit
fb2ca2a4f3
4 changed files with 61 additions and 22 deletions
|
@ -4,12 +4,14 @@ var fs = require("fs");
|
|||
var path = require("path");
|
||||
var enslClient = require(path.join(__dirname, "../lib/ensl/client"))();
|
||||
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
||||
var winston = require("winston");
|
||||
|
||||
module.exports = function (io) {
|
||||
var root = io.of("/");
|
||||
var authorised = io.of("/authorised");
|
||||
|
||||
|
||||
|
||||
var id = 2131;
|
||||
|
||||
// Authorisation
|
||||
|
@ -17,9 +19,11 @@ module.exports = function (io) {
|
|||
enslClient.getUserById({
|
||||
id: id
|
||||
}, function (error, response, body) {
|
||||
if (error) return next(error);
|
||||
if (error) {
|
||||
winston.error(error);
|
||||
return next(error)
|
||||
};
|
||||
socket._user = body;
|
||||
socket._user.avatar = enslClient.getFullAvatarUri(socket._user.avatar);
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
@ -43,6 +47,20 @@ module.exports = function (io) {
|
|||
|
||||
socket.on('refreshGathers', refreshGatherers.bind(null, socket));
|
||||
|
||||
socket.on("authorize:id", function (data) {
|
||||
var id = parseInt(data.id, 10);
|
||||
if (isNaN(id)) return;
|
||||
enslClient.getUserById({
|
||||
id: id
|
||||
}, function (error, response, body) {
|
||||
if (error) {
|
||||
return winston.error(error);
|
||||
}
|
||||
socket._user = body;
|
||||
refreshGatherers();
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('disconnect', function (socket) {
|
||||
refreshGatherers();
|
||||
});
|
||||
|
|
|
@ -16,8 +16,19 @@ var GatherCounter = React.createClass({
|
|||
});
|
||||
|
||||
var UserLogin = React.createClass({
|
||||
handleSubmit: function () {
|
||||
|
||||
authorizeId: function (id) {
|
||||
id = parseInt(id, 10);
|
||||
socket.emit("authorize:id", {
|
||||
id: id
|
||||
});
|
||||
},
|
||||
handleSubmit: function (e) {
|
||||
e.preventDefault();
|
||||
var id = React.findDOMNode(this.refs.authorize_id).value.trim();
|
||||
if (!id) return;
|
||||
React.findDOMNode(this.refs.authorize_id).value = '';
|
||||
this.authorizeId(id);
|
||||
return;
|
||||
},
|
||||
render: function () {
|
||||
return (
|
||||
|
@ -27,6 +38,7 @@ var UserLogin = React.createClass({
|
|||
id="btn-input"
|
||||
type="text"
|
||||
className="form-control"
|
||||
ref="authorize_id"
|
||||
placeholder="Choose an ID..." />
|
||||
<span className="input-group-btn">
|
||||
<input
|
||||
|
@ -152,6 +164,10 @@ var ChatMessage = React.createClass({
|
|||
timeAgo: $.timeago(this.props.createdAt)
|
||||
}
|
||||
},
|
||||
imageUrl: function () {
|
||||
var BASE_URL = "http://www.ensl.org/"
|
||||
return BASE_URL + this.props.avatar;
|
||||
},
|
||||
refreshTime: function () {
|
||||
var self = this;
|
||||
self.setState({
|
||||
|
@ -163,9 +179,10 @@ var ChatMessage = React.createClass({
|
|||
<li className="left clearfix">
|
||||
<span className="chat-img pull-left">
|
||||
<img
|
||||
src={this.props.avatar}
|
||||
src={this.imageUrl()}
|
||||
alt="User Avatar"
|
||||
height="40"
|
||||
width="40"
|
||||
className="img-circle" />
|
||||
</span>
|
||||
<div className="chat-body clearfix">
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -60,19 +60,7 @@
|
|||
|
||||
<div class="navbar-default sidebar" role="navigation">
|
||||
<div class="sidebar-nav navbar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
|
||||
|
||||
<li class="">
|
||||
<a href="#"><i class="fa fa-users-o fa-fw"></i> You</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#"><i class="fa fa-users-o fa-fw"></i> Gatherer #1</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="#"><i class="fa fa-users-o fa-fw"></i> Gatherer #2</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav" id="side-menu"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
Loading…
Reference in a new issue