@@ -268,7 +268,7 @@ const deleteNote = async (req, res) => {
268
268
}
269
269
270
270
const updateNote = async ( req , res ) => {
271
- if ( req . isAuthenticated ( ) ) {
271
+ if ( req . isAuthenticated ( ) || config . allowAnonymousEdits ) {
272
272
const noteId = await Note . parseNoteIdAsync ( req . params . noteId )
273
273
try {
274
274
const note = await Note . findOne ( {
@@ -292,23 +292,25 @@ const updateNote = async (req, res) => {
292
292
title : Note . parseNoteTitle ( content ) ,
293
293
content : content ,
294
294
lastchangeAt : now ,
295
- authorship : [
295
+ authorship : req . isAuthenticated ( ) ? [
296
296
[
297
297
req . user . id ,
298
298
0 ,
299
299
content . length ,
300
300
now ,
301
301
now
302
302
]
303
- ]
303
+ ] : [ ]
304
304
} )
305
305
306
306
if ( ! updated ) {
307
307
logger . error ( 'Update note failed: Write note content error.' )
308
308
return errorInternalError ( req , res )
309
309
}
310
310
311
- updateHistory ( req . user . id , note . id , content )
311
+ if ( req . isAuthenticated ( ) ) {
312
+ updateHistory ( req . user . id , note . id , content )
313
+ }
312
314
313
315
Revision . saveNoteRevision ( note , ( err , revision ) => {
314
316
if ( err ) {
@@ -321,7 +323,7 @@ const updateNote = async (req, res) => {
321
323
} )
322
324
} )
323
325
} catch ( err ) {
324
- logger . error ( err )
326
+ logger . error ( err . stack )
325
327
logger . error ( 'Update note failed: Internal Error.' )
326
328
return errorInternalError ( req , res )
327
329
}
0 commit comments