1
0

Add option to disable registration (#117)

This commit is contained in:
konrad
2019-12-30 23:27:02 +00:00
parent b9f0ba84ab
commit 402cef3c15
8 changed files with 35 additions and 23 deletions

View File

@ -24,11 +24,12 @@ import (
)
type vikunjaInfos struct {
Version string `json:"version"`
FrontendURL string `json:"frontend_url"`
Motd string `json:"motd"`
LinkSharingEnabled bool `json:"link_sharing_enabled"`
MaxFileSize string `json:"max_file_size"`
Version string `json:"version"`
FrontendURL string `json:"frontend_url"`
Motd string `json:"motd"`
LinkSharingEnabled bool `json:"link_sharing_enabled"`
MaxFileSize string `json:"max_file_size"`
RegistrationEnabled bool `json:"registration_enabled"`
}
// Info is the handler to get infos about this vikunja instance
@ -40,10 +41,11 @@ type vikunjaInfos struct {
// @Router /info [get]
func Info(c echo.Context) error {
return c.JSON(http.StatusOK, vikunjaInfos{
Version: version.Version,
FrontendURL: config.ServiceFrontendurl.GetString(),
Motd: config.ServiceMotd.GetString(),
LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(),
MaxFileSize: config.FilesMaxSize.GetString(),
Version: version.Version,
FrontendURL: config.ServiceFrontendurl.GetString(),
Motd: config.ServiceMotd.GetString(),
LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(),
MaxFileSize: config.FilesMaxSize.GetString(),
RegistrationEnabled: config.ServiceEnableRegistration.GetBool(),
})
}

View File

@ -17,6 +17,7 @@
package v1
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
@ -35,6 +36,9 @@ import (
// @Failure 500 {object} models.Message "Internal error"
// @Router /register [post]
func RegisterUser(c echo.Context) error {
if !config.ServiceEnableRegistration.GetBool() {
return echo.ErrNotFound
}
// Check for Request Content
var datUser *models.APIUserPassword
if err := c.Bind(&datUser); err != nil {