Skip to content

Commit

Permalink
Fixing cookie name for self-hosted & more recaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
foodbandlt committed Apr 25, 2016
1 parent 4362e74 commit db5d0cd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion socketserver/socketserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ var SocketServer = function(server){
return;
}

// Return if unauthenticated socket or banned or restricter user tries to do anything other than signup, login, or join room.
// Return if unauthenticated socket or banned or restricted user tries to do anything other than signup, login, or join room.
var restricted = false;
if((!socket.user || (socket.room && that.room.isUserBanned(socket.user.uid)) || (restricted = (Date.now() - socket.user.created) <= config.room.signupcd) || socket.user.confirmation) &&
['signup', 'login', 'joinRoom', 'getUsers', 'getHistory', 'getStaff', 'getBannedUsers', 'confirmation', 'recovery'].indexOf(data.type) == -1){
Expand Down
90 changes: 45 additions & 45 deletions webserver/public/lib/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,9 @@
$('#creds-back').css('display','table');
$('.dash, #app-left, #app-right').hide();
$('#l-email').focus();
grecaptcha.reset();

if (MP.session.isCaptcha)
grecaptcha.reset();
},
hideLogin: function(){
$('#creds-back').hide();
Expand Down Expand Up @@ -2695,9 +2697,12 @@
var server = data.time || client;

MP.session.serverDateDiff = (server < client ? server - client : client - server);
try{
grecaptcha.render('recaptcha', { sitekey: MP.session.captchakey, 'theme': 'dark',});
}catch(e){}

if (MP.session.isCaptcha) {
try{
grecaptcha.render('recaptcha', { sitekey: MP.session.captchakey, 'theme': 'dark',});
}catch(e){}
}
MP.addCurrentToHistory();

$('.btn-grab.active, .btn-upvote.active, .btn-downvote.active').removeClass('active');
Expand Down Expand Up @@ -7329,7 +7334,7 @@
});*/

MP.getTokenName = function() {
if (config.selfHosted == true) {
if (config.selfHosted && location.host.indexOf('musqiqpad.com') != -1) {
if (MP.session.roomInfo.slug) {
return MP.session.roomInfo.slug + '-token';
}
Expand Down Expand Up @@ -7357,54 +7362,49 @@
if (err){
return;
}

if(!MP.historyList.historyInitialized) {
MP.getHistory();
}
// Alpha Only
if (!MP.isLoggedIn()) {
var token = MP.cookie.getCookie(MP.getTokenName());
MP.loginWithTok(token, function(err, data){
if (err){ console.log('Token is invalid.'); return;}
});
}

if (MP.session.roomInfo.bg) { $('#room-bg').css('background-image', 'url('+ MP.session.roomInfo.bg +')'); }
$('title').text(data.room.name);
$('.modal-bg').remove();
var $chat = $('#chat');
MP.loadEmoji(false, function(){
//Remove all current DJ badges and show real badges
var elem = $('#messages .cm.message');
elem.find('.bdg-icon-dj').remove();
elem.find('.bdg:hidden').attr('class', 'bdg');

//Render last chat
for(var i in data.lastChat){
if (data.lastChat[i].user.un && !MP.seenUsers[data.lastChat[i].user.uid]) MP.seenUsers[data.lastChat[i].user.uid] = data.lastChat[i].user;

MP.addMessage({
message: data.lastChat[i].message,
uid: data.lastChat[i].user.uid,
cid: data.lastChat[i].cid,
time: data.lastChat[i].time
});
}

var $chat = $('#chat');
MP.loadEmoji(false, function(){
//Remove all current DJ badges and show real badges
var elem = $('#messages .cm.message');
elem.find('.bdg-icon-dj').remove();
elem.find('.bdg:hidden').attr('class', 'bdg');

//Render last chat
for(var i in data.lastChat){
if (data.lastChat[i].user.un && !MP.seenUsers[data.lastChat[i].user.uid]) MP.seenUsers[data.lastChat[i].user.uid] = data.lastChat[i].user;

MP.addMessage({
message: data.lastChat[i].message,
uid: data.lastChat[i].user.uid,
cid: data.lastChat[i].cid,
time: data.lastChat[i].time
});
}

//Render welcome message
$('#messages').append(
'<div class="cm room-greet">' +
'<div class="mdi mdi-send msg" style="color:#A77DC2"></div>' +
'<div class="text">' +
'<span class="greet-uname">' + MP.emojiReplace(MP.session.roomInfo.name) + '</span>' +
'<br><span class="greet-umsg">' + MP.emojiReplace(MP.session.roomInfo.greet) + '</span></div></div></div>'
);

// Waits for the append to DOM to go through, then scrolls to bottom
setTimeout(function(){
MP.api.chat.scrollBottom();
}, 3);
});
$chat.scrollTop($chat[0].scrollHeight);
//Render welcome message
$('#messages').append(
'<div class="cm room-greet">' +
'<div class="mdi mdi-send msg" style="color:#A77DC2"></div>' +
'<div class="text">' +
'<span class="greet-uname">' + MP.emojiReplace(MP.session.roomInfo.name) + '</span>' +
'<br><span class="greet-umsg">' + MP.emojiReplace(MP.session.roomInfo.greet) + '</span></div></div></div>'
);

// Waits for the append to DOM to go through, then scrolls to bottom
setTimeout(function(){
MP.api.chat.scrollBottom();
}, 3);
});
$chat.scrollTop($chat[0].scrollHeight);

var playerSettings = JSON.parse(localStorage.settings).player;

Expand Down

0 comments on commit db5d0cd

Please sign in to comment.