aboutsummaryrefslogtreecommitdiff
path: root/webcastor.js
diff options
context:
space:
mode:
Diffstat (limited to 'webcastor.js')
-rw-r--r--webcastor.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/webcastor.js b/webcastor.js
index 39c37a9..d1828fc 100644
--- a/webcastor.js
+++ b/webcastor.js
@@ -173,22 +173,33 @@ var Server = {
173 Channel.getPassword(channel, function(hashedPassword) { 173 Channel.getPassword(channel, function(hashedPassword) {
174 174
175 if (hashedPassword === null) { 175 if (hashedPassword === null) {
176 console.log('Client joined an unknown channel'); 176 console.log('Client tried to join an unknown channel');
177 socket.emit('unknown_channel');
177 return; 178 return;
178 } 179 }
179 180
180 socket.join(channel); 181 socket.join(channel);
181 182
182 if (!imports.passwordHash.verify(password, hashedPassword) && hashedPassword !== 'none') { 183 if (password === undefined) {
184
183 console.log('Client joined ' + channel); 185 console.log('Client joined ' + channel);
184 return;
185 }
186 186
187 console.log('Broadcaster joined ' + channel); 187 } else {
188
189 if (hashedPassword === 'none' || imports.passwordHash.verify(password, hashedPassword)) {
190 console.log('Broadcaster joined ' + channel);
191 socket.emit("authenticated");
192
193 socket.on('message', function(event) {
194 Server.broadcast(socket, channel, event);
195 });
196 } else {
197 console.log('Authentication error on channel ' + channel);
198 socket.emit('authentication_error');
199 }
200
201 }
188 202
189 socket.on('message', function(event) {
190 Server.broadcast(socket, channel, event);
191 });
192 }); 203 });
193 }, 204 },
194 205