mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
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
This commit is contained in:
parent
c905fd76c1
commit
a161b59601
8 changed files with 56 additions and 49 deletions
|
@ -217,7 +217,6 @@ exports.checkAccess = function (padID, sessionID, token, password, callback)
|
||||||
else if(!isPublic)
|
else if(!isPublic)
|
||||||
{
|
{
|
||||||
//--> deny access
|
//--> deny access
|
||||||
console.log("not public");
|
|
||||||
statusObject = {accessStatus: "deny"};
|
statusObject = {accessStatus: "deny"};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -228,9 +227,8 @@ exports.checkAccess = function (padID, sessionID, token, password, callback)
|
||||||
// there is no valid session avaiable AND pad doesn't exists
|
// there is no valid session avaiable AND pad doesn't exists
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//--> deny access
|
//grant access so he pad can be generated
|
||||||
console.log("imaginary pad");
|
statusObject = {accessStatus: "grant", authorID: tokenAuthor};
|
||||||
statusObject = {accessStatus: "deny"};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
|
|
@ -190,6 +190,12 @@ exports.handleMessage = function(client, message)
|
||||||
{
|
{
|
||||||
handleSuggestUserName(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
|
//if the message type is unkown, throw an exception
|
||||||
else
|
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
|
* 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
|
* @param client the client that send this message
|
||||||
|
|
|
@ -769,7 +769,7 @@ a#topbarmaximize {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#embed, #readonly {
|
#embed, #readonly, #setpassword {
|
||||||
display:none;
|
display:none;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:40px;
|
top:40px;
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 15px
|
font-size: 15px
|
||||||
}
|
}
|
||||||
input[type="text"], input[type="password"] {
|
input[type="text"] {
|
||||||
width: 243px;
|
width: 243px;
|
||||||
padding: 10px 47px 10px 10px;
|
padding: 10px 47px 10px 10px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
@ -78,13 +78,7 @@
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
text-shadow: 0 0 1px #fff
|
text-shadow: 0 0 1px #fff
|
||||||
}
|
}
|
||||||
#usepwlabel {
|
input[type="submit"] {
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
#usePasswordContainer {
|
|
||||||
margin: 10px 0 5px 0
|
|
||||||
}
|
|
||||||
input[type="submit"] {
|
|
||||||
width: 45px;
|
width: 45px;
|
||||||
margin-left: -50px;
|
margin-left: -50px;
|
||||||
padding: 8px
|
padding: 8px
|
||||||
|
@ -100,8 +94,6 @@
|
||||||
<form action="#" onsubmit="go2Name();return false;">
|
<form action="#" onsubmit="go2Name();return false;">
|
||||||
<input type="text" id="padname" autofocus/>
|
<input type="text" id="padname" autofocus/>
|
||||||
<input type="submit" value="OK"/><br/>
|
<input type="submit" value="OK"/><br/>
|
||||||
<div id="usePasswordContainer"><input type="checkbox" id="usePassword" onclick="updatePasswordField()"/><label for="usePassword"><div id="usepwlabel">Use password</div></label></div>
|
|
||||||
<div id="passwordFieldContainer"><input type="password" id="passwordField"/></div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
@ -109,20 +101,7 @@
|
||||||
{
|
{
|
||||||
var padname = $("#padname").val();
|
var padname = $("#padname").val();
|
||||||
if(padname.length > 0){
|
if(padname.length > 0){
|
||||||
if($("#passwordField").val().length>0)
|
window.location = "p/" + padname;
|
||||||
{
|
|
||||||
$.get("api/1/createPad", {apikey: "o8PJ496RtbcwoMQGgDyjoOmyq5wJ8dON", padID: padname}, function(data){
|
|
||||||
$.get("api/1/setPassword", {apikey: "o8PJ496RtbcwoMQGgDyjoOmyq5wJ8dON", padID: padname, password: $("#passwordField").val()}, function(data){
|
|
||||||
window.location = "p/" + padname;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$.get("api/1/createPad", {apikey: "o8PJ496RtbcwoMQGgDyjoOmyq5wJ8dON", padID: padname}, function(data){
|
|
||||||
window.location = "p/" + padname;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -146,18 +125,6 @@
|
||||||
}
|
}
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePasswordField()
|
|
||||||
{
|
|
||||||
if($("#usePassword:checked").val()){
|
|
||||||
$("#passwordFieldContainer").css("display", "block");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#passwordFieldContainer").css("display", "none");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updatePasswordField();
|
|
||||||
if(typeof customStart == "function") customStart();
|
if(typeof customStart == "function") customStart();
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -3471,7 +3471,7 @@ function OUTER(gscope)
|
||||||
function handleClick(evt)
|
function handleClick(evt)
|
||||||
{
|
{
|
||||||
//hide the dropdowns
|
//hide the dropdowns
|
||||||
window.top.padeditbar.toogleDropDown("none");
|
window.top.padeditbar.toggleDropDown("none");
|
||||||
|
|
||||||
inCallStack("handleClick", function()
|
inCallStack("handleClick", function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,11 @@ function createCookie(name, value, days, path)
|
||||||
document.cookie = name + "=" + value + expires + "; path=" + path;
|
document.cookie = name + "=" + value + expires + "; path=" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPassword(){
|
||||||
|
console.log("setting password");
|
||||||
|
pad.setPassword($("#setpasswordfield").val());
|
||||||
|
}
|
||||||
|
|
||||||
function readCookie(name)
|
function readCookie(name)
|
||||||
{
|
{
|
||||||
var nameEQ = name + "=";
|
var nameEQ = name + "=";
|
||||||
|
@ -489,6 +494,13 @@ var pad = {
|
||||||
changedBy: pad.myUserInfo.name || "unnamed"
|
changedBy: pad.myUserInfo.name || "unnamed"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setPassword: function(newPassword){
|
||||||
|
pad.collabClient.sendClientMessage(
|
||||||
|
{
|
||||||
|
type: "setPassword",
|
||||||
|
password: newPassword
|
||||||
|
});
|
||||||
|
},
|
||||||
changeViewOption: function(key, value)
|
changeViewOption: function(key, value)
|
||||||
{
|
{
|
||||||
var options = {
|
var options = {
|
||||||
|
|
|
@ -96,18 +96,18 @@ var padeditbar = (function()
|
||||||
{
|
{
|
||||||
if(cmd == "showusers")
|
if(cmd == "showusers")
|
||||||
{
|
{
|
||||||
self.toogleDropDown("users");
|
self.toggleDropDown("users");
|
||||||
}
|
}
|
||||||
else if (cmd == 'embed')
|
else if (cmd == 'embed')
|
||||||
{
|
{
|
||||||
var padurl = window.location.href.split("?")[0];
|
var padurl = window.location.href.split("?")[0];
|
||||||
$('#embedinput').val("<iframe src='" + padurl + "?showControls=true&showChat=true&showLineNumbers=true&useMonospaceFont=false' width=600 height=400>");
|
$('#embedinput').val("<iframe src='" + padurl + "?showControls=true&showChat=true&showLineNumbers=true&useMonospaceFont=false' width=600 height=400>");
|
||||||
self.toogleDropDown("embed");
|
self.toggleDropDown("embed");
|
||||||
$('#embedinput').focus().select();
|
$('#embedinput').focus().select();
|
||||||
}
|
}
|
||||||
else if (cmd == 'import_export')
|
else if (cmd == 'import_export')
|
||||||
{
|
{
|
||||||
self.toogleDropDown("importexport");
|
self.toggleDropDown("importexport");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == 'readonly')
|
else if (cmd == 'readonly')
|
||||||
|
@ -116,13 +116,16 @@ var padeditbar = (function()
|
||||||
var readonlyLink = basePath + "/ro/" + clientVars.readOnlyId;
|
var readonlyLink = basePath + "/ro/" + clientVars.readOnlyId;
|
||||||
$('#readonlyImage').attr("src","https://chart.googleapis.com/chart?chs=200x200&cht=qr&chld=H|0&chl=" + readonlyLink);
|
$('#readonlyImage').attr("src","https://chart.googleapis.com/chart?chs=200x200&cht=qr&chld=H|0&chl=" + readonlyLink);
|
||||||
$('#readonlyInput').val(readonlyLink);
|
$('#readonlyInput').val(readonlyLink);
|
||||||
self.toogleDropDown("readonly");
|
self.toggleDropDown("readonly");
|
||||||
$('#readonlyInput').focus().select();
|
$('#readonlyInput').focus().select();
|
||||||
}
|
}
|
||||||
else if (cmd == 'save')
|
else if (cmd == 'save')
|
||||||
{
|
{
|
||||||
padsavedrevs.saveNow();
|
padsavedrevs.saveNow();
|
||||||
}
|
}
|
||||||
|
else if (cmd == 'password'){
|
||||||
|
self.toggleDropDown("setpassword");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
padeditor.ace.callWithAce(function(ace)
|
padeditor.ace.callWithAce(function(ace)
|
||||||
|
@ -162,9 +165,9 @@ var padeditbar = (function()
|
||||||
}
|
}
|
||||||
padeditor.ace.focus();
|
padeditor.ace.focus();
|
||||||
},
|
},
|
||||||
toogleDropDown: function(moduleName)
|
toggleDropDown: function(moduleName)
|
||||||
{
|
{
|
||||||
var modules = ["embed", "users", "readonly", "importexport"];
|
var modules = ["embed", "users", "readonly", "importexport", "setpassword"];
|
||||||
|
|
||||||
//hide all modules
|
//hide all modules
|
||||||
if(moduleName == "none")
|
if(moduleName == "none")
|
||||||
|
|
|
@ -96,6 +96,11 @@
|
||||||
<div class="buttonicon" style="background-position:0px -18px"></div>
|
<div class="buttonicon" style="background-position:0px -18px"></div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li onClick="window.pad&&pad.editbarClick('password');return false;" >
|
||||||
|
<a id="setpasswordlink" title="Set the password of this pad">
|
||||||
|
<div class="buttonicon" style="background-position:0px -18px"></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="separator"></li>
|
<li class="separator"></li>
|
||||||
<li id="timesliderlink" onClick="document.location = document.location.pathname+ '/timeslider'">
|
<li id="timesliderlink" onClick="document.location = document.location.pathname+ '/timeslider'">
|
||||||
<a title="Show the history of this pad">
|
<a title="Show the history of this pad">
|
||||||
|
@ -178,6 +183,15 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- password setting code -->
|
||||||
|
|
||||||
|
<div id="setpassword">
|
||||||
|
<form id="setpasswordform" action="">
|
||||||
|
<input type="password" id="setpasswordfield">
|
||||||
|
<input type="submit" value="Set" id="setpasswordsubmit" onClick="setPassword()">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- import export code -->
|
<!-- import export code -->
|
||||||
<div id="importexport">
|
<div id="importexport">
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue