Skip to content
Snippets Groups Projects
Unverified Commit faf29b76 authored by syuilo's avatar syuilo
Browse files

Make admin can delete any note

parent 7576569d
No related branches found
No related tags found
No related merge requests found
......@@ -33,12 +33,16 @@ export default Vue.extend({
text: '%i18n:@pin%',
action: this.pin
});
}
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
items.push({
icon: '%fa:trash-alt R%',
text: '%i18n:@delete%',
action: this.del
});
}
if (this.note.uri) {
items.push({
icon: '%fa:external-link-square-alt%',
......@@ -48,6 +52,7 @@ export default Vue.extend({
}
});
}
return items;
}
},
......
......@@ -21,14 +21,17 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
// Fetch note
const note = await Note.findOne({
_id: noteId,
userId: user._id
_id: noteId
});
if (note === null) {
return rej('note not found');
}
if (!user.isAdmin && !note.userId.equals(user._id)) {
return rej('access denied');
}
await deleteNote(user, note);
res();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment