return error entity when verify email is not enabled
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
)
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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': '当前认证令牌已过期',
|
||||
|
||||
Reference in New Issue
Block a user