mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
Add spam control basics
This commit is contained in:
parent
e10d04d22e
commit
51a0e1127e
8 changed files with 101 additions and 12 deletions
|
@ -85,17 +85,21 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
|
|||
response.WriteMissingDataError(w, method, "email")
|
||||
return
|
||||
}
|
||||
|
||||
if len(userModel.Firstname) == 0 {
|
||||
response.WriteMissingDataError(w, method, "firsrtname")
|
||||
return
|
||||
}
|
||||
|
||||
if len(userModel.Lastname) == 0 {
|
||||
response.WriteMissingDataError(w, method, "lastname")
|
||||
return
|
||||
}
|
||||
|
||||
// Spam checks.
|
||||
if mail.IsBlockedEmailDomain(userModel.Email) {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
userModel.Initials = stringutil.MakeInitials(userModel.Firstname, userModel.Lastname)
|
||||
requestedPassword := secrets.GenerateRandomPassword()
|
||||
userModel.Salt = secrets.GenerateSalt()
|
||||
|
@ -808,6 +812,13 @@ func (h *Handler) BulkImport(w http.ResponseWriter, r *http.Request) {
|
|||
userID = uniqueid.Generate()
|
||||
userModel.RefID = userID
|
||||
|
||||
// Spam checks.
|
||||
if mail.IsBlockedEmailDomain(userModel.Email) {
|
||||
ctx.Transaction.Rollback()
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
err = h.Store.User.Add(ctx, userModel)
|
||||
if err != nil {
|
||||
ctx.Transaction.Rollback()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue