forked from mirrors/homebox
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
This commit is contained in:
parent
dd349aa98e
commit
efd7069fe4
7 changed files with 27 additions and 14 deletions
|
@ -2,6 +2,7 @@ version: "3"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_fk=1
|
HBOX_STORAGE_SQLITE_URL: .data/homebox.db?_fk=1
|
||||||
|
HBOX_OPTIONS_ALLOW_REGISTRATION: true
|
||||||
UNSAFE_DISABLE_PASSWORD_PROJECTION: "yes_i_am_sure"
|
UNSAFE_DISABLE_PASSWORD_PROJECTION: "yes_i_am_sure"
|
||||||
tasks:
|
tasks:
|
||||||
setup:
|
setup:
|
||||||
|
|
|
@ -50,6 +50,7 @@ type (
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Build Build `json:"build"`
|
Build Build `json:"build"`
|
||||||
Demo bool `json:"demo"`
|
Demo bool `json:"demo"`
|
||||||
|
AllowRegistration bool `json:"allowRegistration"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) server.Handle
|
||||||
Message: "Welcome to the Go API Template Application!",
|
Message: "Welcome to the Go API Template Application!",
|
||||||
Build: build,
|
Build: build,
|
||||||
Demo: ctrl.isDemo,
|
Demo: ctrl.isDemo,
|
||||||
|
AllowRegistration: ctrl.allowRegistration,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2425,6 +2425,9 @@ const docTemplate = `{
|
||||||
"v1.ApiSummary": {
|
"v1.ApiSummary": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"allowRegistration": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"$ref": "#/definitions/v1.Build"
|
"$ref": "#/definitions/v1.Build"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2417,6 +2417,9 @@
|
||||||
"v1.ApiSummary": {
|
"v1.ApiSummary": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"allowRegistration": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"$ref": "#/definitions/v1.Build"
|
"$ref": "#/definitions/v1.Build"
|
||||||
},
|
},
|
||||||
|
|
|
@ -564,6 +564,8 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
v1.ApiSummary:
|
v1.ApiSummary:
|
||||||
properties:
|
properties:
|
||||||
|
allowRegistration:
|
||||||
|
type: boolean
|
||||||
build:
|
build:
|
||||||
$ref: '#/definitions/v1.Build'
|
$ref: '#/definitions/v1.Build'
|
||||||
demo:
|
demo:
|
||||||
|
|
|
@ -335,6 +335,7 @@ export interface ActionAmountResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiSummary {
|
export interface ApiSummary {
|
||||||
|
allowRegistration: boolean;
|
||||||
build: Build;
|
build: Build;
|
||||||
demo: boolean;
|
demo: boolean;
|
||||||
health: boolean;
|
health: boolean;
|
||||||
|
|
|
@ -101,7 +101,6 @@
|
||||||
|
|
||||||
toast.success("Logged in successfully");
|
toast.success("Logged in successfully");
|
||||||
|
|
||||||
// @ts-expect-error - expires is either a date or a string, need to figure out store typing
|
|
||||||
authStore.$patch({
|
authStore.$patch({
|
||||||
token: data.token,
|
token: data.token,
|
||||||
expires: data.expiresAt,
|
expires: data.expiresAt,
|
||||||
|
@ -214,11 +213,13 @@
|
||||||
</Transition>
|
</Transition>
|
||||||
<div class="text-center mt-6">
|
<div class="text-center mt-6">
|
||||||
<button
|
<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()"
|
@click="() => toggleLogin()"
|
||||||
>
|
>
|
||||||
{{ registerForm ? "Already a User? Login" : "Not a User? Register" }}
|
{{ registerForm ? "Login" : "Register" }}
|
||||||
</button>
|
</button>
|
||||||
|
<p v-else class="text-base-content italic text-sm">Registration Disabled</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue