setting.advance.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package main
  2. import (
  3. "net/http"
  4. autologin "imuslab.com/arozos/mod/auth/autologin"
  5. prout "imuslab.com/arozos/mod/prouter"
  6. "imuslab.com/arozos/mod/utils"
  7. )
  8. /*
  9. Advance Setting Group
  10. This is a function group that help handles system advance functions
  11. */
  12. func AdvanceSettingInit() {
  13. /*
  14. Define common routers
  15. */
  16. adminRouter := prout.NewModuleRouter(prout.RouterOption{
  17. ModuleName: "System Settings",
  18. AdminOnly: true,
  19. UserHandler: userHandler,
  20. DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
  21. utils.SendErrorResponse(w, "Permission Denied")
  22. },
  23. })
  24. /*
  25. Billboard mode / Bot login mode
  26. This method allows users or machine to login with token instead of login interface
  27. */
  28. registerSetting(settingModule{
  29. Name: "Auto Login Mode",
  30. Desc: "Allow bots logging into the system automatically",
  31. IconPath: "SystemAO/advance/img/small_icon.png",
  32. Group: "Advance",
  33. StartDir: "SystemAO/advance/autologin.html",
  34. RequireAdmin: true,
  35. })
  36. autoLoginHandler := autologin.NewAutoLoginHandler(userHandler)
  37. adminRouter.HandleFunc("/system/autologin/list", autoLoginHandler.HandleUserTokensListing)
  38. adminRouter.HandleFunc("/system/autologin/create", autoLoginHandler.HandleUserTokenCreation)
  39. adminRouter.HandleFunc("/system/autologin/delete", autoLoginHandler.HandleUserTokenRemoval)
  40. /*
  41. Advance Disk Management Interface
  42. This methods allow hot swapping / mounting of storage devices
  43. */
  44. if *allow_hardware_management {
  45. registerSetting(settingModule{
  46. Name: "Disk Manager",
  47. Desc: "Mount, Unmount and Formatting Local Disks",
  48. IconPath: "SystemAO/disk/img/small_icon.png",
  49. Group: "Advance",
  50. StartDir: "SystemAO/disk/diskmg.html",
  51. RequireAdmin: true,
  52. })
  53. }
  54. }