Merge branch 'feat/0.7.0/user-manage' into test

This commit is contained in:
LinkinStar 2022-12-16 17:19:18 +08:00
commit c3fc2fda63
3 changed files with 9 additions and 1 deletions

View File

@ -198,6 +198,10 @@ func (uc *UserController) UseRePassWord(ctx *gin.Context) {
// @Router /answer/api/v1/user/logout [get] // @Router /answer/api/v1/user/logout [get]
func (uc *UserController) UserLogout(ctx *gin.Context) { func (uc *UserController) UserLogout(ctx *gin.Context) {
accessToken := middleware.ExtractToken(ctx) accessToken := middleware.ExtractToken(ctx)
if len(accessToken) == 0 {
handler.HandleResponse(ctx, nil, nil)
return
}
_ = uc.authService.RemoveUserCacheInfo(ctx, accessToken) _ = uc.authService.RemoveUserCacheInfo(ctx, accessToken)
handler.HandleResponse(ctx, nil, nil) handler.HandleResponse(ctx, nil, nil)
} }

View File

@ -73,6 +73,10 @@ func InitDB(dataConf *data.Database) (err error) {
if err != nil { if err != nil {
return fmt.Errorf("sync table failed: %s", err) return fmt.Errorf("sync table failed: %s", err)
} }
_, err = engine.InsertOne(&entity.Version{ID: 1, VersionNumber: ExpectedVersion()})
if err != nil {
return fmt.Errorf("init version table failed: %s", err)
}
err = initAdminUser(engine) err = initAdminUser(engine)
if err != nil { if err != nil {

View File

@ -109,6 +109,7 @@ func (a *AnswerAPIRouter) RegisterMustUnAuthAnswerAPIRouter(r *gin.RouterGroup)
func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) { func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {
// user // user
r.GET("/user/logout", a.userController.UserLogout)
r.POST("/user/email/change/code", a.userController.UserChangeEmailSendCode) r.POST("/user/email/change/code", a.userController.UserChangeEmailSendCode)
r.POST("/user/email/verification/send", a.userController.UserVerifyEmailSend) r.POST("/user/email/verification/send", a.userController.UserVerifyEmailSend)
r.GET("/personal/user/info", a.userController.GetOtherUserInfoByUsername) r.GET("/personal/user/info", a.userController.GetOtherUserInfoByUsername)
@ -196,7 +197,6 @@ func (a *AnswerAPIRouter) RegisterAnswerAPIRouter(r *gin.RouterGroup) {
r.DELETE("/answer", a.answerController.RemoveAnswer) r.DELETE("/answer", a.answerController.RemoveAnswer)
// user // user
r.GET("/user/logout", a.userController.UserLogout)
r.PUT("/user/password", a.userController.UserModifyPassWord) r.PUT("/user/password", a.userController.UserModifyPassWord)
r.PUT("/user/info", a.userController.UserUpdateInfo) r.PUT("/user/info", a.userController.UserUpdateInfo)
r.PUT("/user/interface", a.userController.UserUpdateInterface) r.PUT("/user/interface", a.userController.UserUpdateInterface)