A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat: user can change email when email hasn't been verified.
LinkinStarb162fcbee01f
diff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.goindex 42a65792..07ad63cd 100644--- a/internal/controller/user_controller.go+++ b/internal/controller/user_controller.go@@ -480,6 +480,12 @@ func (uc *UserController) UserChangeEmailSendCode(ctx *gin.Context) {return}req.UserID = middleware.GetLoginUserIDFromContext(ctx)+ // If the user is not logged in, the api cannot be used.+ // If the user email is not verified, that also can use this api to modify the email.+ if len(req.UserID) == 0 {+ handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)+ return+ }err := uc.userService.UserChangeEmailSendCode(ctx, req)handler.HandleResponse(ctx, err, nil)diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.goindex e227a10f..781f92d2 100644--- a/internal/router/answer_api_router.go+++ b/internal/router/answer_api_router.go@@ -98,6 +98,7 @@ func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {r.POST("/user/email/verification/send", a.userController.UserVerifyEmailSend)r.GET("/user/logout", a.userController.UserLogout)r.PUT("/user/email", a.userController.UserChangeEmailVerify)+ r.POST("/user/email/change/code", a.userController.UserChangeEmailSendCode)//answerr.GET("/answer/info", a.answerController.Get)@@ -179,7 +180,6 @@ func (a *AnswerAPIRouter) RegisterAnswerAPIRouter(r *gin.RouterGroup) {r.POST("/user/avatar/upload", a.userController.UploadUserAvatar)r.POST("/user/post/file", a.userController.UploadUserPostFile)r.POST("/user/notice/set", a.userController.UserNoticeSet)- r.POST("/user/email/change/code", a.userController.UserChangeEmailSendCode)// voter.GET("/personal/vote/page", a.voteController.UserVotes)