diff --git a/pkg/api/users.go b/pkg/api/users.go index 6a42ca7c..347aa090 100644 --- a/pkg/api/users.go +++ b/pkg/api/users.go @@ -410,6 +410,10 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs // UserSendVerifyEmailByUnloginUserHandler sends unlogin user verify email func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (interface{}, *errs.Error) { + if !settings.Container.Current.EnableUserVerifyEmail { + return nil, errs.ErrEmailValidationNotAllowed + } + var userResendVerifyEmailReq models.UserResendVerifyEmailRequest err := c.ShouldBindJSON(&userResendVerifyEmailReq) @@ -462,6 +466,10 @@ func (a *UsersApi) UserSendVerifyEmailByUnloginUserHandler(c *core.Context) (int // UserSendVerifyEmailByLoginedUserHandler sends logined user verify email func (a *UsersApi) UserSendVerifyEmailByLoginedUserHandler(c *core.Context) (interface{}, *errs.Error) { + if !settings.Container.Current.EnableUserVerifyEmail { + return nil, errs.ErrEmailValidationNotAllowed + } + uid := c.GetCurrentUid() user, err := a.users.GetUserById(c, uid) diff --git a/pkg/cli/user_data.go b/pkg/cli/user_data.go index b9122e1b..fd32ddf9 100644 --- a/pkg/cli/user_data.go +++ b/pkg/cli/user_data.go @@ -236,6 +236,10 @@ func (l *UserDataCli) DisableUser(c *cli.Context, username string) error { // ResendVerifyEmail resends an email with account activation link func (l *UserDataCli) ResendVerifyEmail(c *cli.Context, username string) error { + if !settings.Container.Current.EnableUserVerifyEmail { + return errs.ErrEmailValidationNotAllowed + } + if username == "" { log.BootErrorf("[user_data.ResendVerifyEmail] user name is empty") return errs.ErrUsernameIsEmpty diff --git a/pkg/errs/user.go b/pkg/errs/user.go index 677bb35d..28c7fee2 100644 --- a/pkg/errs/user.go +++ b/pkg/errs/user.go @@ -28,4 +28,5 @@ var ( ErrNewPasswordEqualsOldInvalid = NewNormalError(NormalSubcategoryUser, 19, http.StatusBadRequest, "new password equals old password") ErrEmailIsNotVerified = NewNormalError(NormalSubcategoryUser, 20, http.StatusBadRequest, "email is not verified") ErrEmailIsVerified = NewNormalError(NormalSubcategoryUser, 21, http.StatusBadRequest, "email is verified") + ErrEmailValidationNotAllowed = NewNormalError(NormalSubcategoryUser, 22, http.StatusBadRequest, "email validation not allowed") ) diff --git a/src/locales/en.js b/src/locales/en.js index 37096165..5bac1e69 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -586,6 +586,7 @@ export default { 'new password equals old password': 'New password equals old password', 'email is not verified': 'Email is not verified', 'email is verified': 'Email is verified', + 'email validation not allowed': 'Email validation is not allowed', 'unauthorized access': 'Unauthorized access', 'current token is invalid': 'Current token is invalid', 'current token is expired': 'Current token is expired', diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index a1d476f9..45d38915 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -586,6 +586,7 @@ export default { 'new password equals old password': '新密码与旧密码相同', 'email is not verified': '邮箱还未验证通过', 'email is verified': '邮箱已经验证过', + 'email validation not allowed': '不允许邮箱验证', 'unauthorized access': '未授权的登录', 'current token is invalid': '当前认证令牌无效', 'current token is expired': '当前认证令牌已过期',