Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit efd7069

Browse files
authored
feat: hide registration button when disabled (#287)
* add allow registration to API Summary * code gen * use env for troubleshooting * disable registration toggle based on backend
1 parent dd349aa commit efd7069

File tree

7 files changed

+27
-14
lines changed

7 files changed

+27
-14
lines changed

Diff for: Taskfile.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: "3"
22

33
env:
44
HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_fk=1
5+
HBOX_OPTIONS_ALLOW_REGISTRATION: true
56
UNSAFE_DISABLE_PASSWORD_PROJECTION: "yes_i_am_sure"
67
tasks:
78
setup:

Diff for: backend/app/api/handlers/v1/controller.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ type (
4444
}
4545

4646
ApiSummary struct {
47-
Healthy bool `json:"health"`
48-
Versions []string `json:"versions"`
49-
Title string `json:"title"`
50-
Message string `json:"message"`
51-
Build Build `json:"build"`
52-
Demo bool `json:"demo"`
47+
Healthy bool `json:"health"`
48+
Versions []string `json:"versions"`
49+
Title string `json:"title"`
50+
Message string `json:"message"`
51+
Build Build `json:"build"`
52+
Demo bool `json:"demo"`
53+
AllowRegistration bool `json:"allowRegistration"`
5354
}
5455
)
5556

@@ -82,11 +83,12 @@ func NewControllerV1(svc *services.AllServices, repos *repo.AllRepos, options ..
8283
func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) server.HandlerFunc {
8384
return func(w http.ResponseWriter, r *http.Request) error {
8485
return server.Respond(w, http.StatusOK, ApiSummary{
85-
Healthy: ready(),
86-
Title: "Go API Template",
87-
Message: "Welcome to the Go API Template Application!",
88-
Build: build,
89-
Demo: ctrl.isDemo,
86+
Healthy: ready(),
87+
Title: "Go API Template",
88+
Message: "Welcome to the Go API Template Application!",
89+
Build: build,
90+
Demo: ctrl.isDemo,
91+
AllowRegistration: ctrl.allowRegistration,
9092
})
9193
}
9294
}

Diff for: backend/app/api/static/docs/docs.go

+3
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,9 @@ const docTemplate = `{
24252425
"v1.ApiSummary": {
24262426
"type": "object",
24272427
"properties": {
2428+
"allowRegistration": {
2429+
"type": "boolean"
2430+
},
24282431
"build": {
24292432
"$ref": "#/definitions/v1.Build"
24302433
},

Diff for: backend/app/api/static/docs/swagger.json

+3
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,9 @@
24172417
"v1.ApiSummary": {
24182418
"type": "object",
24192419
"properties": {
2420+
"allowRegistration": {
2421+
"type": "boolean"
2422+
},
24202423
"build": {
24212424
"$ref": "#/definitions/v1.Build"
24222425
},

Diff for: backend/app/api/static/docs/swagger.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ definitions:
564564
type: object
565565
v1.ApiSummary:
566566
properties:
567+
allowRegistration:
568+
type: boolean
567569
build:
568570
$ref: '#/definitions/v1.Build'
569571
demo:

Diff for: frontend/lib/api/types/data-contracts.ts

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ export interface ActionAmountResult {
335335
}
336336

337337
export interface ApiSummary {
338+
allowRegistration: boolean;
338339
build: Build;
339340
demo: boolean;
340341
health: boolean;

Diff for: frontend/pages/index.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
102102
toast.success("Logged in successfully");
103103
104-
// @ts-expect-error - expires is either a date or a string, need to figure out store typing
105104
authStore.$patch({
106105
token: data.token,
107106
expires: data.expiresAt,
@@ -214,11 +213,13 @@
214213
</Transition>
215214
<div class="text-center mt-6">
216215
<button
217-
class="text-base-content text-lg hover:bg-primary hover:text-primary-content px-3 py-1 rounded-xl transition-colors duration-200"
216+
v-if="status && status.allowRegistration"
217+
class="btn text-base-content text-lg hover:bg-primary hover:text-primary-content transition-colors duration-200"
218218
@click="() => toggleLogin()"
219219
>
220-
{{ registerForm ? "Already a User? Login" : "Not a User? Register" }}
220+
{{ registerForm ? "Login" : "Register" }}
221221
</button>
222+
<p v-else class="text-base-content italic text-sm">Registration Disabled</p>
222223
</div>
223224
</div>
224225
</div>

0 commit comments

Comments
 (0)