Merge pull request #313 from elct9620/feature/disable_anonymous_view
WIP: Add options to limit anonymous view note
This commit is contained in:
commit
a8068d38d5
5 changed files with 47 additions and 20 deletions
|
@ -23,7 +23,7 @@ var logger = require("../logger.js");
|
|||
var ot = require("../ot/index.js");
|
||||
|
||||
// permission types
|
||||
var permissionTypes = ["freely", "editable", "locked", "private"];
|
||||
var permissionTypes = ["freely", "editable", "limited", "private", "protected", "locked"];
|
||||
|
||||
module.exports = function (sequelize, DataTypes) {
|
||||
var Note = sequelize.define("Note", {
|
||||
|
|
|
@ -618,12 +618,12 @@ function ifMayEdit(socket, callback) {
|
|||
case "freely":
|
||||
//not blocking anyone
|
||||
break;
|
||||
case "editable":
|
||||
case "editable": case "limited":
|
||||
//only login user can change
|
||||
if (!socket.request.user || !socket.request.user.logged_in)
|
||||
mayEdit = false;
|
||||
break;
|
||||
case "locked": case "private":
|
||||
case "locked": case "private": case "protected":
|
||||
//only owner can change
|
||||
if (!note.owner || note.owner != socket.request.user.id)
|
||||
mayEdit = false;
|
||||
|
|
|
@ -124,6 +124,11 @@ function checkViewPermission(req, note) {
|
|||
return false;
|
||||
else
|
||||
return true;
|
||||
} else if (note.permission == 'limited' || note.permission == 'protected') {
|
||||
if( !req.isAuthenticated() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -857,7 +857,9 @@ window.ui = {
|
|||
freely: $(".ui-permission-freely"),
|
||||
editable: $(".ui-permission-editable"),
|
||||
locked: $(".ui-permission-locked"),
|
||||
private: $(".ui-permission-private")
|
||||
private: $(".ui-permission-private"),
|
||||
limited: $(".ui-permission-limited"),
|
||||
protected: $(".ui-permission-protected")
|
||||
},
|
||||
delete: $(".ui-delete-note")
|
||||
},
|
||||
|
@ -2247,6 +2249,14 @@ ui.infobar.permission.locked.click(function () {
|
|||
ui.infobar.permission.private.click(function () {
|
||||
emitPermission("private");
|
||||
});
|
||||
//limited
|
||||
ui.infobar.permission.limited.click(function() {
|
||||
emitPermission("limited");
|
||||
});
|
||||
//protected
|
||||
ui.infobar.permission.protected.click(function() {
|
||||
emitPermission("protected");
|
||||
});
|
||||
// delete note
|
||||
ui.infobar.delete.click(function () {
|
||||
$('.delete-modal').modal('show');
|
||||
|
@ -2277,14 +2287,22 @@ function updatePermission(newPermission) {
|
|||
label = '<i class="fa fa-shield"></i> Editable';
|
||||
title = "Signed people can edit";
|
||||
break;
|
||||
case "locked":
|
||||
label = '<i class="fa fa-lock"></i> Locked';
|
||||
title = "Only owner can edit";
|
||||
case "limited":
|
||||
label = '<i class="fa fa-id-card"></i> Limited';
|
||||
title = "Signed people can edit & guest can't view"
|
||||
break;
|
||||
case "private":
|
||||
label = '<i class="fa fa-hand-stop-o"></i> Private';
|
||||
title = "Only owner can view & edit";
|
||||
break;
|
||||
case "protected":
|
||||
label = '<i class="fa fa-umbrella"></i> Protected';
|
||||
title = "Only owner can edit & guest can't view";
|
||||
break;
|
||||
case "locked":
|
||||
label = '<i class="fa fa-lock"></i> Locked';
|
||||
title = "Only owner can edit";
|
||||
break;
|
||||
}
|
||||
if (personalInfo.userid && owner && personalInfo.userid == owner) {
|
||||
label += ' <i class="fa fa-caret-down"></i>';
|
||||
|
@ -2302,6 +2320,7 @@ function havePermission() {
|
|||
bool = true;
|
||||
break;
|
||||
case "editable":
|
||||
case "limited":
|
||||
if (!personalInfo.login) {
|
||||
bool = false;
|
||||
} else {
|
||||
|
@ -2310,6 +2329,7 @@ function havePermission() {
|
|||
break;
|
||||
case "locked":
|
||||
case "private":
|
||||
case "protected":
|
||||
if (!owner || personalInfo.userid != owner) {
|
||||
bool = false;
|
||||
} else {
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
<ul class="dropdown-menu" aria-labelledby="permissionLabel">
|
||||
<li class="ui-permission-freely"<% if(!allowAnonymous) { %> style="display: none;"<% } %>><a><i class="fa fa-leaf fa-fw"></i> Freely - Anyone can edit</a></li>
|
||||
<li class="ui-permission-editable"><a><i class="fa fa-shield fa-fw"></i> Editable - Signed people can edit</a></li>
|
||||
<li class="ui-permission-locked"><a><i class="fa fa-lock fa-fw"></i> Locked - Only owner can edit</a></li>
|
||||
<li class="ui-permission-limited"><a><i class="fa fa-id-card fa-fw"></i> Limited - Signed people can edit & view</a></li>
|
||||
<li class="ui-permission-private"><a><i class="fa fa-hand-stop-o fa-fw"></i> Private - Only owner can view & edit</a></li>
|
||||
<li class="ui-permission-protected"><a><i class="fa fa-umbrella fa-fw"></i> Protected - Only owner can edit</a></li>
|
||||
<li class="ui-permission-locked"><a><i class="fa fa-lock fa-fw"></i> Locked - Only owner can edit</a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="ui-delete-note"><a><i class="fa fa-trash-o fa-fw"></i> Delete this note</a></li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue