parent
bee58b421d
commit
92d73026be
13
channel.js
13
channel.js
|
@ -201,6 +201,19 @@ Channel.prototype.searchLibrary = function(query) {
|
|||
|
||||
// Called when a new user enters the channel
|
||||
Channel.prototype.userJoin = function(user) {
|
||||
// Prevent duplicate login
|
||||
if(user.name != "") {
|
||||
for(var i = 0; i < this.users.length; i++) {
|
||||
if(this.users[i].name == user.name) {
|
||||
user.name = "";
|
||||
user.loggedIn = false;
|
||||
user.socket.emit('login', {
|
||||
success: false,
|
||||
error: "The username " + user.name + " is already in use on this channel"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the channel is empty and isn't registered, the first person
|
||||
// gets ownership of the channel (temporarily)
|
||||
if(this.users.length == 0 && !this.registered) {
|
||||
|
|
11
user.js
11
user.js
|
@ -226,6 +226,17 @@ User.prototype.handleAdm = function(data) {
|
|||
|
||||
// Attempt to login
|
||||
User.prototype.login = function(name, sha256) {
|
||||
if(this.channel != null && name != "") {
|
||||
for(var i = 0; i < this.channel.users.length; i++) {
|
||||
if(this.channel.users[i].name == name) {
|
||||
this.socket.emit('login', {
|
||||
success: false,
|
||||
error: "The username " + name + " is already in use on this channel"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No password => try guest login
|
||||
if(sha256 == "") {
|
||||
// Sorry bud, can't take that name
|
||||
|
|
Loading…
Reference in a new issue