mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-09 13:51:57 -04:00
Add limited and protected permission
This commit is contained in:
parent
c21fb8e2a0
commit
89b8ddeaba
5 changed files with 43 additions and 16 deletions
|
@ -251,13 +251,13 @@ function getStatus(callback) {
|
|||
return logger.error('count user failed: ' + err);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
return logger.error('count note failed: ' + err);
|
||||
return logger.error('count note failed: ' + err);
|
||||
});
|
||||
}
|
||||
|
||||
function isReady() {
|
||||
return realtime.io
|
||||
&& Object.keys(notes).length == 0 && Object.keys(users).length == 0
|
||||
return realtime.io
|
||||
&& Object.keys(notes).length == 0 && Object.keys(users).length == 0
|
||||
&& connectionSocketQueue.length == 0 && !isConnectionBusy
|
||||
&& disconnectSocketQueue.length == 0 && !isDisconnectBusy;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ function finishConnection(socket, note, user) {
|
|||
function startConnection(socket) {
|
||||
if (isConnectionBusy) return;
|
||||
isConnectionBusy = true;
|
||||
|
||||
|
||||
var noteId = socket.noteId;
|
||||
if (!noteId) {
|
||||
return failConnection(404, 'note id not found', socket);
|
||||
|
@ -521,7 +521,7 @@ function disconnect(socket) {
|
|||
logger.info("SERVER disconnected a client");
|
||||
logger.info(JSON.stringify(users[socket.id]));
|
||||
}
|
||||
|
||||
|
||||
if (users[socket.id]) {
|
||||
delete users[socket.id];
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -672,7 +672,7 @@ function operationCallback(socket, operation) {
|
|||
var noteId = note.alias ? note.alias : LZString.compressToBase64(note.id);
|
||||
if (note.server) history.updateHistory(userId, noteId, note.server.document);
|
||||
}, 0);
|
||||
|
||||
|
||||
}
|
||||
// save authorship
|
||||
note.authorship = models.Note.updateAuthorshipByOperation(operation, userId, note.authorship);
|
||||
|
@ -689,10 +689,10 @@ function connection(socket) {
|
|||
}
|
||||
|
||||
if (isDuplicatedInSocketQueue(socket, connectionSocketQueue)) return;
|
||||
|
||||
|
||||
// store noteId in this socket session
|
||||
socket.noteId = noteId;
|
||||
|
||||
|
||||
//initialize user data
|
||||
//random color
|
||||
var color = randomcolor();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue