A continuation of HomeBox the inventory and organization system built for the Home User
feat: hide registration button when disabled (#287)
Haydenefd7069fe4d3
diff --git a/Taskfile.yml b/Taskfile.ymlindex 816077ac..a16daa55 100644--- a/Taskfile.yml+++ b/Taskfile.yml@@ -2,6 +2,7 @@ version: "3"env:HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_fk=1+ HBOX_OPTIONS_ALLOW_REGISTRATION: trueUNSAFE_DISABLE_PASSWORD_PROJECTION: "yes_i_am_sure"tasks:setup:diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.goindex 4f7a73e6..f5790c8b 100644--- a/backend/app/api/handlers/v1/controller.go+++ b/backend/app/api/handlers/v1/controller.go@@ -44,12 +44,13 @@ type (}ApiSummary struct {- Healthy bool `json:"health"`- Versions []string `json:"versions"`- Title string `json:"title"`- Message string `json:"message"`- Build Build `json:"build"`- Demo bool `json:"demo"`+ Healthy bool `json:"health"`+ Versions []string `json:"versions"`+ Title string `json:"title"`+ Message string `json:"message"`+ Build Build `json:"build"`+ Demo bool `json:"demo"`+ AllowRegistration bool `json:"allowRegistration"`})@@ -82,11 +83,12 @@ func NewControllerV1(svc *services.AllServices, repos *repo.AllRepos, options ..func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) server.HandlerFunc {return func(w http.ResponseWriter, r *http.Request) error {return server.Respond(w, http.StatusOK, ApiSummary{- Healthy: ready(),- Title: "Go API Template",- Message: "Welcome to the Go API Template Application!",- Build: build,- Demo: ctrl.isDemo,+ Healthy: ready(),+ Title: "Go API Template",+ Message: "Welcome to the Go API Template Application!",+ Build: build,+ Demo: ctrl.isDemo,+ AllowRegistration: ctrl.allowRegistration,})}}diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.goindex 3f7c37d7..e24f1407 100644--- a/backend/app/api/static/docs/docs.go+++ b/backend/app/api/static/docs/docs.go@@ -2425,6 +2425,9 @@ const docTemplate = `{"v1.ApiSummary": {"type": "object","properties": {+ "allowRegistration": {+ "type": "boolean"+ },"build": {"$ref": "#/definitions/v1.Build"},diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.jsonindex 3c814567..6319ff90 100644--- a/backend/app/api/static/docs/swagger.json+++ b/backend/app/api/static/docs/swagger.json@@ -2417,6 +2417,9 @@"v1.ApiSummary": {"type": "object","properties": {+ "allowRegistration": {+ "type": "boolean"+ },"build": {"$ref": "#/definitions/v1.Build"},diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yamlindex 4d7db79c..301dd3df 100644--- a/backend/app/api/static/docs/swagger.yaml+++ b/backend/app/api/static/docs/swagger.yaml@@ -564,6 +564,8 @@ definitions:type: objectv1.ApiSummary:properties:+ allowRegistration:+ type: booleanbuild:$ref: '#/definitions/v1.Build'demo:diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.tsindex 9ed4a8dc..a4a0d908 100644--- a/frontend/lib/api/types/data-contracts.ts+++ b/frontend/lib/api/types/data-contracts.ts@@ -335,6 +335,7 @@ export interface ActionAmountResult {}export interface ApiSummary {+ allowRegistration: boolean;build: Build;demo: boolean;health: boolean;diff --git a/frontend/pages/index.vue b/frontend/pages/index.vueindex 423ec7d4..a7846e2c 100644--- a/frontend/pages/index.vue+++ b/frontend/pages/index.vue@@ -101,7 +101,6 @@toast.success("Logged in successfully");- // @ts-expect-error - expires is either a date or a string, need to figure out store typingauthStore.$patch({token: data.token,expires: data.expiresAt,@@ -214,11 +213,13 @@</Transition><div class="text-center mt-6"><button- class="text-base-content text-lg hover:bg-primary hover:text-primary-content px-3 py-1 rounded-xl transition-colors duration-200"+ v-if="status && status.allowRegistration"+ class="btn text-base-content text-lg hover:bg-primary hover:text-primary-content transition-colors duration-200"@click="() => toggleLogin()">- {{ registerForm ? "Already a User? Login" : "Not a User? Register" }}+ {{ registerForm ? "Login" : "Register" }}</button>+ <p v-else class="text-base-content italic text-sm">Registration Disabled</p></div></div></div>