email: Add option to require on sign-up

for #172
This commit is contained in:
Harvey Tindall
2021-12-20 18:44:31 +00:00
parent 9fff5781f4
commit 0fd4f516b1
6 changed files with 32 additions and 1 deletions

5
api.go
View File

@@ -644,6 +644,11 @@ func (app *appContext) NewUser(gc *gin.Context) {
gc.JSON(200, validation)
return
}
if emailEnabled && app.config.Section("email").Key("required").MustBool(false) && !strings.Contains(req.Email, "@") {
app.info.Printf("%s: New user failed: Email Required", req.Code)
respond(400, "errorNoEmail", gc)
return
}
f, success := app.newUser(req, false)
if !success {
f(gc)