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