Add a configuration to disable signing up
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/appcontext"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/dto"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/model"
|
||||
@@ -9,6 +12,14 @@ import (
|
||||
)
|
||||
|
||||
func PostSignupHandler(ac appcontext.AppContext) {
|
||||
if ac.Config.DisableRegistration {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac,
|
||||
myvalidator.HttpError{
|
||||
StatusCode: http.StatusForbidden,
|
||||
Err: errors.New("Registration has been disabled on this instance."),
|
||||
})
|
||||
return
|
||||
}
|
||||
var user dto.UserSignup
|
||||
err := ac.C.ShouldBindJSON(&user)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user