Add default permission config#348
Conversation
|
Hi @nvsofts |
|
By the way: may check https://github.com/SISheogorath/hackmd/commit/1ce93737670a02e4da7462103fd233d57e5aa400 |
|
To mention it: it's untested which is the reason why I didn't open a PR |
f55ffb2 to
0a7adaf
Compare
|
@jackycute use |
|
You still have a problem with an inconsistent database entry in case you have a typo in your default permission as you don't do a real validation. That should never happen. Edit: Let me correct: you end up in a loop of rejections of the note. As your database model tries to set an invalid entry. That's ugly... |
|
Hmm, I think @SISheogorath was right about the validation. |
|
Wait a sec, hold on @nvsofts |
|
|
||
| var allowfreeurl = process.env.HMD_ALLOW_FREEURL ? (process.env.HMD_ALLOW_FREEURL === 'true') : !!config.allowfreeurl; | ||
|
|
||
| var defaultpermission = process.env.HMD_DEFAULT_PERMISSION || config.defaultpermission || 'editable'; |
There was a problem hiding this comment.
Please validate the permission passed to here is in the scopes.
We have 6 permission types for now.
| | usecdn | `true` or `false` | set to use CDN resources or not (default is `true`) | | ||
| | allowanonymous | `true` or `false` | set to allow anonymous usage (default is `true`) | | ||
| | allowfreeurl | `true` or `false` | set to allow new note by accessing not exist note url | | ||
| | defaultpermission | `freely`, `editable`, `limited`, `locked` or `private` | when creates new note, uses this permission (only applied when logged in) | |
There was a problem hiding this comment.
I would prefer following description:
set notes default permission (only applied on signed users)
| | HMD_USECDN | `true` or `false` | set to use CDN resources or not (default is `true`) | | ||
| | HMD_ALLOW_ANONYMOUS | `true` or `false` | set to allow anonymous usage (default is `true`) | | ||
| | HMD_ALLOW_FREEURL | `true` or `false` | set to allow new note by accessing not exist note url | | ||
| | HMD_DEFAULT_PERMISSION | `freely`, `editable`, `limited`, `locked` or `private` | when creates new note, uses this permission (only applied when logged in) | |
There was a problem hiding this comment.
I would prefer following description:
set notes default permission (only applied on signed users)
|
@SISheogorath @jackycute followed. |
|
Well, that was a fast move 😄 |
|
@jackycute maybe I should stop writing everything into a single line :D |
|
@SISheogorath Yeah, always consider readability even on writing code. |
Use
defaultpermission(config.json) orHMD_DEFAULT_PERMISSION(environment value) to set default permission of newly created note.