taskcafe/internal/api/settings.go
Jordan Knott 64093e19f6 redesign
2022-05-06 16:44:31 -05:00

24 lines
611 B
Go

package api
import (
"encoding/json"
"net/http"
"github.com/sirupsen/logrus"
)
type PublicSettingsResponseData struct {
IsInstalled bool `json:"isInstalled"`
AllowPublicRegistration bool `json:"allowPublicRegistration`
}
func (api *TaskcafeApi) PublicSettings(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
isInstalled, err := api.Data.HasAnyUserAccount(ctx)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
logrus.WithError(err).Error()
}
json.NewEncoder(w).Encode(PublicSettingsResponseData{IsInstalled: isInstalled, AllowPublicRegistration: false})
}