From a161b596012a5b8dedb237456b4f53f2d8015dec Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 8 Dec 2011 22:45:54 +0100 Subject: [PATCH] Now working. The password can be set from within the pad editor. Currently there are only two remaining issues: 1 After the password is set, re-authentication is needed 2 The toolbar button does not yet have a nice icon --- node/db/SecurityManager.js | 6 ++--- node/handler/PadMessageHandler.js | 13 +++++++++++ static/css/pad.css | 4 ++-- static/index.html | 39 +++---------------------------- static/js/ace2_inner.js | 2 +- static/js/pad2.js | 12 ++++++++++ static/js/pad_editbar.js | 15 +++++++----- static/pad.html | 14 +++++++++++ 8 files changed, 56 insertions(+), 49 deletions(-) diff --git a/node/db/SecurityManager.js b/node/db/SecurityManager.js index fa7780dc3..c7d98a58b 100644 --- a/node/db/SecurityManager.js +++ b/node/db/SecurityManager.js @@ -217,7 +217,6 @@ exports.checkAccess = function (padID, sessionID, token, password, callback) else if(!isPublic) { //--> deny access - console.log("not public"); statusObject = {accessStatus: "deny"}; } else @@ -228,9 +227,8 @@ exports.checkAccess = function (padID, sessionID, token, password, callback) // there is no valid session avaiable AND pad doesn't exists else { - //--> deny access - console.log("imaginary pad"); - statusObject = {accessStatus: "deny"}; + //grant access so he pad can be generated + statusObject = {accessStatus: "grant", authorID: tokenAuthor}; } callback(); diff --git a/node/handler/PadMessageHandler.js b/node/handler/PadMessageHandler.js index 56e6de873..7aa1238e8 100644 --- a/node/handler/PadMessageHandler.js +++ b/node/handler/PadMessageHandler.js @@ -190,6 +190,12 @@ exports.handleMessage = function(client, message) { handleSuggestUserName(client, message); } + else if(message.type == "COLLABROOM" && + message.data.type == "CLIENT_MESSAGE" && + message.data.payload.type == "setPassword") + { + handleSetPadPassword(client, message); + } //if the message type is unkown, throw an exception else { @@ -294,6 +300,13 @@ function handleSuggestUserName(client, message) } } +function handleSetPadPassword(client, message){ + var padId = session2pad[client.id]; + padManager.getPad(padId, function(err, value){ + value.setPassword(message.data.payload.password); + }); +} + /** * Handles a USERINFO_UPDATE, that means that a user have changed his color or name. Anyway, we get both informations * @param client the client that send this message diff --git a/static/css/pad.css b/static/css/pad.css index 3d170c3dd..bdab50409 100644 --- a/static/css/pad.css +++ b/static/css/pad.css @@ -769,7 +769,7 @@ a#topbarmaximize { width: 100%; } -#embed, #readonly { +#embed, #readonly, #setpassword { display:none; position:absolute; top:40px; @@ -1146,4 +1146,4 @@ width:33px !important; #editbar ul li { padding: 4px 1px; } -} \ No newline at end of file +} diff --git a/static/index.html b/static/index.html index 1c35e3852..09b4b2164 100644 --- a/static/index.html +++ b/static/index.html @@ -69,7 +69,7 @@ font-weight: bold; font-size: 15px } - input[type="text"], input[type="password"] { + input[type="text"] { width: 243px; padding: 10px 47px 10px 10px; background: #fff; @@ -78,13 +78,7 @@ border-radius: 3px; text-shadow: 0 0 1px #fff } - #usepwlabel { - display: inline; - } - #usePasswordContainer { - margin: 10px 0 5px 0 - } - input[type="submit"] { + input[type="submit"] { width: 45px; margin-left: -50px; padding: 8px @@ -100,8 +94,6 @@

-
-
diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 1575fc9ad..7b136f1e5 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -3471,7 +3471,7 @@ function OUTER(gscope) function handleClick(evt) { //hide the dropdowns - window.top.padeditbar.toogleDropDown("none"); + window.top.padeditbar.toggleDropDown("none"); inCallStack("handleClick", function() { diff --git a/static/js/pad2.js b/static/js/pad2.js index 568b34568..8534d6d84 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -51,6 +51,11 @@ function createCookie(name, value, days, path) document.cookie = name + "=" + value + expires + "; path=" + path; } +function setPassword(){ + console.log("setting password"); + pad.setPassword($("#setpasswordfield").val()); +} + function readCookie(name) { var nameEQ = name + "="; @@ -489,6 +494,13 @@ var pad = { changedBy: pad.myUserInfo.name || "unnamed" }); }, + setPassword: function(newPassword){ + pad.collabClient.sendClientMessage( + { + type: "setPassword", + password: newPassword + }); + }, changeViewOption: function(key, value) { var options = { diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index ae1090687..253f2884d 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -96,18 +96,18 @@ var padeditbar = (function() { if(cmd == "showusers") { - self.toogleDropDown("users"); + self.toggleDropDown("users"); } else if (cmd == 'embed') { var padurl = window.location.href.split("?")[0]; $('#embedinput').val("