1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Remove "Create Account" button when AllowSignup is set to false (#319)

Merge pull request #319
This commit is contained in:
Roch D'Amour 2022-02-16 02:56:27 -05:00 committed by GitHub
parent 3758eecc96
commit ac9d96c563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 10 deletions

View File

@ -1,9 +1,10 @@
package view
type LoginViewModel struct {
Success string
Error string
TotalUsers int
Success string
Error string
TotalUsers int
AllowSignup bool
}
type SetPasswordViewModel struct {

View File

@ -299,10 +299,12 @@ func (h *LoginHandler) PostResetPassword(w http.ResponseWriter, r *http.Request)
func (h *LoginHandler) buildViewModel(r *http.Request) *view.LoginViewModel {
numUsers, _ := h.userSrvc.Count()
allowSignup := h.config.Security.AllowSignup
return &view.LoginViewModel{
Success: r.URL.Query().Get("success"),
Error: r.URL.Query().Get("error"),
TotalUsers: int(numUsers),
Success: r.URL.Query().Get("success"),
Error: r.URL.Query().Get("error"),
TotalUsers: int(numUsers),
AllowSignup: allowSignup,
}
}

View File

@ -57,6 +57,10 @@ body {
@apply py-2 px-4 font-semibold rounded bg-gray-800 hover:bg-gray-850 text-white text-sm;
}
.btn-disabled {
@apply py-2 px-4 font-semibold rounded bg-gray-800 text-gray-600 text-sm;
}
.btn-primary {
@apply py-2 px-4 font-semibold rounded bg-green-700 hover:bg-green-800 text-white text-sm;
}

File diff suppressed because one or more lines are too long

View File

@ -31,9 +31,15 @@
Forgot password?
</a>
<div class="flex space-x-2">
{{ if eq .AllowSignup true }}
<a href="signup">
<button type="button" class="btn-default">Sign up</button>
</a>
{{ else }}
<a title="The administrator of this instance has disabled sign up.">
<button type="button" class="btn-disabled" disabled > Sign up </button>
</a>
{{ end }}
<button type="submit" class="btn-primary">Log in</button>
</div>
</div>

View File

@ -83,9 +83,15 @@
<a href="login">
<button type="button" class="btn-default">Log in</button>
</a>
{{ if eq .AllowSignup true }}
<button type="submit" class="btn-primary">
Create Account
</button>
{{ else }}
<button type="submit" class="btn-disabled" disabled title="The administrator of this instance has disabled sign up.">
Create Account
</button>
{{ end }}
</div>
</form>
</div>