Added support for changing username from the URL ie ?userName=JohnMcLear -- doesnt urldecode etc. needs checking for vulnerabilities too

This commit is contained in:
John McLear 2011-08-13 19:53:02 +01:00
parent 7f28889660
commit bba9cd515b
1 changed files with 18 additions and 2 deletions

View File

@ -18,6 +18,7 @@
var socket; var socket;
var LineNumbersDisabled = false; var LineNumbersDisabled = false;
var globalUserName = false;
$(document).ready(function() $(document).ready(function()
{ {
@ -97,10 +98,15 @@ function getParams()
{ {
if(showLineNumbers == "false") if(showLineNumbers == "false")
{ {
// pad.changeViewOption('showLineNumbers', false);
LineNumbersDisabled = true; LineNumbersDisabled = true;
} }
} }
if(userName)
{
// If the username is set as a parameter we should set a global value that we can call once we have initiated the pad.
globalUserName = userName;
}
} }
function getUrlVars() function getUrlVars()
@ -170,10 +176,20 @@ function handshake()
pad.init(); pad.init();
initalized = true; initalized = true;
// If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers
if (LineNumbersDisabled == true) if (LineNumbersDisabled == true)
{ {
pad.changeViewOption('showLineNumbers', false); $ pad.changeViewOption('showLineNumbers', false);
} }
// if the globalUserName value is set we need to tell the server and the client about the new authorname
if (globalUserName !== false)
{
pad.notifyChangeName(globalUserName); // Notifies the server
$('#myusernameedit').attr({"value":globalUserName}); // Updates the current users UI
}
} }
//This handles every Message after the clientVars //This handles every Message after the clientVars
else else