The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
669 B

  1. module.exports = class {
  2. onCreate() {
  3. this.state = {
  4. permitted: false
  5. }
  6. }
  7. onInput(input) {
  8. console.log(input.user, input.permission)
  9. if (!input.user || !input.user.loggedIn) {
  10. this.state.permitted = false
  11. return
  12. }
  13. if (input.author != null && input.author != "" && input.user.name === input.author) {
  14. this.state.permitted = input.user.permissions.includes("member")
  15. } else if (Array.isArray(input.permission)) {
  16. this.state.permitted = input.user.permissions.find(p => input.permission.includes(p))
  17. } else {
  18. this.state.permitted = input.user.permissions.includes(input.permission)
  19. }
  20. }
  21. }