mirror of https://gitee.com/answerdev/answer.git
Merge remote-tracking branch 'origin/feat/1.0.2/user' into test
This commit is contained in:
commit
36020bdbd6
|
@ -111,6 +111,9 @@ backend:
|
|||
other: "No permission to update."
|
||||
cannot_set_synonym_as_itself:
|
||||
other: "You cannot set the synonym of the current tag as itself."
|
||||
smtp:
|
||||
config_from_name_cannot_be_email:
|
||||
other: "The From Name cannot be a email address."
|
||||
theme:
|
||||
not_found:
|
||||
other: "Theme not found."
|
||||
|
|
|
@ -60,4 +60,5 @@ const (
|
|||
UserCannotUpdateYourRole = "error.user.cannot_update_your_role"
|
||||
TagCannotSetSynonymAsItself = "error.tag.cannot_set_synonym_as_itself"
|
||||
NotAllowedRegistration = "error.user.not_allowed_registration"
|
||||
SMTPConfigFromNameCannotBeEmail = "error.smtp.config_from_name_cannot_be_email"
|
||||
)
|
||||
|
|
|
@ -3,10 +3,14 @@ package schema
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
|
||||
"github.com/answerdev/answer/internal/base/handler"
|
||||
"github.com/answerdev/answer/internal/base/reason"
|
||||
"github.com/answerdev/answer/internal/base/translator"
|
||||
"github.com/answerdev/answer/internal/base/validator"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
)
|
||||
|
||||
const PermaLinkQuestionIDAndTitle = 1
|
||||
|
@ -190,6 +194,17 @@ type UpdateSMTPConfigReq struct {
|
|||
TestEmailRecipient string `validate:"omitempty,email" json:"test_email_recipient"`
|
||||
}
|
||||
|
||||
func (r *UpdateSMTPConfigReq) Check() (errField []*validator.FormErrorField, err error) {
|
||||
_, err = mail.ParseAddress(r.FromName)
|
||||
if err == nil {
|
||||
return append(errField, &validator.FormErrorField{
|
||||
ErrorField: "from_name",
|
||||
ErrorMsg: reason.SMTPConfigFromNameCannotBeEmail,
|
||||
}), errors.BadRequest(reason.SMTPConfigFromNameCannotBeEmail)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// GetSMTPConfigResp get smtp config response
|
||||
type GetSMTPConfigResp struct {
|
||||
FromEmail string `json:"from_email"`
|
||||
|
|
Loading…
Reference in New Issue