This commit is contained in:
linkinstar 2022-11-23 08:38:26 +00:00
commit 8c1c1a664c
12 changed files with 200 additions and 130 deletions

View File

@ -26,6 +26,10 @@ backend:
answer: answer:
not_found: not_found:
other: "Answer do not found." other: "Answer do not found."
cannot_deleted:
other: "No permission to delete."
cannot_update:
other: "No permission to update."
comment: comment:
edit_without_permission: edit_without_permission:
other: "Comment are not allowed to edit." other: "Comment are not allowed to edit."
@ -63,6 +67,12 @@ backend:
question: question:
not_found: not_found:
other: "Question not found." other: "Question not found."
cannot_deleted:
other: "No permission to delete."
cannot_close:
other: "No permission to close."
cannot_update:
other: "No permission to update."
rank: rank:
fail_to_meet_the_condition: fail_to_meet_the_condition:
other: "Rank fail to meet the condition." other: "Rank fail to meet the condition."
@ -76,6 +86,8 @@ backend:
other: "Tag not found." other: "Tag not found."
recommend_tag_not_found: recommend_tag_not_found:
other: "Recommend Tag is not exist." other: "Recommend Tag is not exist."
recommend_tag_enter:
other: "Please enter at least one required tag."
not_contain_synonym_tags: not_contain_synonym_tags:
other: "Should not contain synonym tags." other: "Should not contain synonym tags."
theme: theme:
@ -94,7 +106,6 @@ backend:
other: "Username is already in use." other: "Username is already in use."
set_avatar: set_avatar:
other: "Avatar set failed." other: "Avatar set failed."
config: config:
read_config_failed: read_config_failed:
other: "Read config failed" other: "Read config failed"

View File

@ -17,7 +17,12 @@ const (
EmailOrPasswordWrong = "error.object.email_or_password_incorrect" EmailOrPasswordWrong = "error.object.email_or_password_incorrect"
CommentNotFound = "error.comment.not_found" CommentNotFound = "error.comment.not_found"
QuestionNotFound = "error.question.not_found" QuestionNotFound = "error.question.not_found"
QuestionCannotDeleted = "error.question.cannot_deleted"
QuestionCannotClose = "error.question.cannot_close"
QuestionCannotUpdate = "error.question.cannot_update"
AnswerNotFound = "error.answer.not_found" AnswerNotFound = "error.answer.not_found"
AnswerCannotDeleted = "error.answer.cannot_deleted"
AnswerCannotUpdate = "error.answer.cannot_update"
CommentEditWithoutPermission = "error.comment.edit_without_permission" CommentEditWithoutPermission = "error.comment.edit_without_permission"
DisallowVote = "error.object.disallow_vote" DisallowVote = "error.object.disallow_vote"
DisallowFollow = "error.object.disallow_follow" DisallowFollow = "error.object.disallow_follow"

View File

@ -55,7 +55,8 @@ func (ac *AnswerController) RemoveAnswer(ctx *gin.Context) {
handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition)) handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition))
return return
} }
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
err := ac.answerService.RemoveAnswer(ctx, req) err := ac.answerService.RemoveAnswer(ctx, req)
handler.HandleResponse(ctx, err, nil) handler.HandleResponse(ctx, err, nil)
} }
@ -147,6 +148,8 @@ func (ac *AnswerController) Update(ctx *gin.Context) {
return return
} }
req.UserID = middleware.GetLoginUserIDFromContext(ctx) req.UserID = middleware.GetLoginUserIDFromContext(ctx)
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
if can, err := ac.rankService.CheckRankPermission(ctx, req.UserID, rank.AnswerEditRank); err != nil || !can { if can, err := ac.rankService.CheckRankPermission(ctx, req.UserID, rank.AnswerEditRank); err != nil || !can {
handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition)) handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition))
@ -190,6 +193,8 @@ func (ac *AnswerController) AnswerList(ctx *gin.Context) {
return return
} }
req.LoginUserID = middleware.GetLoginUserIDFromContext(ctx) req.LoginUserID = middleware.GetLoginUserIDFromContext(ctx)
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
list, count, err := ac.answerService.SearchList(ctx, req) list, count, err := ac.answerService.SearchList(ctx, req)
if err != nil { if err != nil {
handler.HandleResponse(ctx, err, nil) handler.HandleResponse(ctx, err, nil)

View File

@ -43,9 +43,11 @@ func (qc *QuestionController) RemoveQuestion(ctx *gin.Context) {
} }
req.UserID = middleware.GetLoginUserIDFromContext(ctx) req.UserID = middleware.GetLoginUserIDFromContext(ctx)
if can, err := qc.rankService.CheckRankPermission(ctx, req.UserID, rank.QuestionDeleteRank); err != nil || !can { if can, err := qc.rankService.CheckRankPermission(ctx, req.UserID, rank.QuestionDeleteRank); err != nil || !can {
handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition)) handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), errors.Forbidden(reason.RankFailToMeetTheCondition))
return return
} }
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
err := qc.questionService.RemoveQuestion(ctx, req) err := qc.questionService.RemoveQuestion(ctx, req)
handler.HandleResponse(ctx, err, nil) handler.HandleResponse(ctx, err, nil)
@ -67,6 +69,8 @@ func (qc *QuestionController) CloseQuestion(ctx *gin.Context) {
return return
} }
req.UserID = middleware.GetLoginUserIDFromContext(ctx) req.UserID = middleware.GetLoginUserIDFromContext(ctx)
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
err := qc.questionService.CloseQuestion(ctx, req) err := qc.questionService.CloseQuestion(ctx, req)
handler.HandleResponse(ctx, err, nil) handler.HandleResponse(ctx, err, nil)
} }
@ -85,7 +89,8 @@ func (qc *QuestionController) GetQuestion(c *gin.Context) {
id := c.Query("id") id := c.Query("id")
ctx := context.Background() ctx := context.Background()
userID := middleware.GetLoginUserIDFromContext(c) userID := middleware.GetLoginUserIDFromContext(c)
info, err := qc.questionService.GetQuestion(ctx, id, userID, true) userinfo := middleware.GetUserInfoFromContext(c)
info, err := qc.questionService.GetQuestion(ctx, id, userID, true, userinfo.IsAdmin)
if err != nil { if err != nil {
handler.HandleResponse(c, err, nil) handler.HandleResponse(c, err, nil)
return return
@ -213,7 +218,8 @@ func (qc *QuestionController) UpdateQuestion(ctx *gin.Context) {
return return
} }
req.UserID = middleware.GetLoginUserIDFromContext(ctx) req.UserID = middleware.GetLoginUserIDFromContext(ctx)
userinfo := middleware.GetUserInfoFromContext(ctx)
req.IsAdmin = userinfo.IsAdmin
if can, err := qc.rankService.CheckRankPermission(ctx, req.UserID, rank.QuestionEditRank); err != nil || !can { if can, err := qc.rankService.CheckRankPermission(ctx, req.UserID, rank.QuestionEditRank); err != nil || !can {
handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition)) handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition))
return return

View File

@ -6,6 +6,7 @@ type RemoveAnswerReq struct {
ID string `validate:"required" json:"id"` ID string `validate:"required" json:"id"`
// user id // user id
UserID string `json:"-"` UserID string `json:"-"`
IsAdmin bool `json:"-"`
} }
const ( const (
@ -28,6 +29,7 @@ type AnswerUpdateReq struct {
Content string `json:"content"` // content Content string `json:"content"` // content
HTML string `json:"html" ` // html HTML string `json:"html" ` // html
EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary
IsAdmin bool `json:"-"`
} }
type AnswerList struct { type AnswerList struct {
@ -36,6 +38,7 @@ type AnswerList struct {
Page int `json:"page" form:"page"` // Query number of pages Page int `json:"page" form:"page"` // Query number of pages
PageSize int `json:"page_size" form:"page_size"` // Search page size PageSize int `json:"page_size" form:"page_size"` // Search page size
LoginUserID string `json:"-" ` LoginUserID string `json:"-" `
IsAdmin bool `json:"-"`
} }
type AnswerInfo struct { type AnswerInfo struct {

View File

@ -5,6 +5,7 @@ type RemoveQuestionReq struct {
// question id // question id
ID string `validate:"required" comment:"question id" json:"id"` ID string `validate:"required" comment:"question id" json:"id"`
UserID string `json:"-" ` // user_id UserID string `json:"-" ` // user_id
IsAdmin bool `json:"-"`
} }
type CloseQuestionReq struct { type CloseQuestionReq struct {
@ -12,6 +13,7 @@ type CloseQuestionReq struct {
UserID string `json:"-" ` // user_id UserID string `json:"-" ` // user_id
CloseType int `json:"close_type" ` // close_type CloseType int `json:"close_type" ` // close_type
CloseMsg string `json:"close_msg" ` // close_type CloseMsg string `json:"close_msg" ` // close_type
IsAdmin bool `json:"-"`
} }
type CloseQuestionMeta struct { type CloseQuestionMeta struct {
@ -47,6 +49,7 @@ type QuestionUpdate struct {
EditSummary string `validate:"omitempty" json:"edit_summary"` EditSummary string `validate:"omitempty" json:"edit_summary"`
// user id // user id
UserID string `json:"-"` UserID string `json:"-"`
IsAdmin bool `json:"-"`
} }
type QuestionBaseInfo struct { type QuestionBaseInfo struct {

View File

@ -73,27 +73,29 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, req *schema.RemoveAns
if !exist { if !exist {
return nil return nil
} }
if !req.IsAdmin {
if answerInfo.UserID != req.UserID { if answerInfo.UserID != req.UserID {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
if answerInfo.VoteCount > 0 { if answerInfo.VoteCount > 0 {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
if answerInfo.Adopted == schema.AnswerAdoptedEnable { if answerInfo.Adopted == schema.AnswerAdoptedEnable {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, answerInfo.QuestionID) questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, answerInfo.QuestionID)
if err != nil { if err != nil {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
if !exist { if !exist {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
if questionInfo.AnswerCount > 1 { if questionInfo.AnswerCount > 1 {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
} }
if questionInfo.AcceptedAnswerID != "" { if questionInfo.AcceptedAnswerID != "" {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.AnswerCannotDeleted)
}
} }
// user add question count // user add question count
@ -180,6 +182,19 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
if !exist { if !exist {
return "", errors.BadRequest(reason.QuestionNotFound) return "", errors.BadRequest(reason.QuestionNotFound)
} }
if !req.IsAdmin {
answerInfo, exist, err := as.answerRepo.GetByID(ctx, req.ID)
if err != nil {
return "", err
}
if !exist {
return "", nil
}
if answerInfo.UserID != req.UserID {
return "", errors.BadRequest(reason.AnswerCannotUpdate)
}
}
now := time.Now() now := time.Now()
insertData := new(entity.Answer) insertData := new(entity.Answer)
insertData.ID = req.ID insertData.ID = req.ID
@ -377,14 +392,14 @@ func (as *AnswerService) SearchList(ctx context.Context, search *schema.AnswerLi
if err != nil { if err != nil {
return list, count, err return list, count, err
} }
AnswerList, err := as.SearchFormatInfo(ctx, dblist, search.LoginUserID) AnswerList, err := as.SearchFormatInfo(ctx, dblist, search.LoginUserID, search.IsAdmin)
if err != nil { if err != nil {
return AnswerList, count, err return AnswerList, count, err
} }
return AnswerList, count, nil return AnswerList, count, nil
} }
func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.Answer, loginUserID string) ([]*schema.AnswerInfo, error) { func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.Answer, loginUserID string, isAdmin bool) ([]*schema.AnswerInfo, error) {
list := make([]*schema.AnswerInfo, 0) list := make([]*schema.AnswerInfo, 0)
objectIds := make([]string, 0) objectIds := make([]string, 0)
userIds := make([]string, 0) userIds := make([]string, 0)
@ -427,7 +442,7 @@ func (as *AnswerService) SearchFormatInfo(ctx context.Context, dblist []*entity.
} }
for _, item := range list { for _, item := range list {
item.MemberActions = permission.GetAnswerPermission(loginUserID, item.UserID) item.MemberActions = permission.GetAnswerPermission(ctx, loginUserID, item.UserID, isAdmin)
} }
return list, nil return list, nil

View File

@ -121,7 +121,7 @@ func (cs *CommentService) AddComment(ctx context.Context, req *schema.AddComment
resp = &schema.GetCommentResp{} resp = &schema.GetCommentResp{}
resp.SetFromComment(comment) resp.SetFromComment(comment)
resp.MemberActions = permission.GetCommentPermission(req.UserID, resp.UserID) resp.MemberActions = permission.GetCommentPermission(ctx, req.UserID, resp.UserID)
// get reply user info // get reply user info
if len(resp.ReplyUserID) > 0 { if len(resp.ReplyUserID) > 0 {
@ -222,7 +222,7 @@ func (cs *CommentService) GetComment(ctx context.Context, req *schema.GetComment
// check if current user vote this comment // check if current user vote this comment
resp.IsVote = cs.checkIsVote(ctx, req.UserID, resp.CommentID) resp.IsVote = cs.checkIsVote(ctx, req.UserID, resp.CommentID)
resp.MemberActions = permission.GetCommentPermission(req.UserID, resp.UserID) resp.MemberActions = permission.GetCommentPermission(ctx, req.UserID, resp.UserID)
return resp, nil return resp, nil
} }
@ -282,7 +282,7 @@ func (cs *CommentService) GetCommentWithPage(ctx context.Context, req *schema.Ge
// check if current user vote this comment // check if current user vote this comment
commentResp.IsVote = cs.checkIsVote(ctx, req.UserID, commentResp.CommentID) commentResp.IsVote = cs.checkIsVote(ctx, req.UserID, commentResp.CommentID)
commentResp.MemberActions = permission.GetCommentPermission(req.UserID, commentResp.UserID) commentResp.MemberActions = permission.GetCommentPermission(ctx, req.UserID, commentResp.UserID)
resp = append(resp, commentResp) resp = append(resp, commentResp)
} }
return pager.NewPageModel(total, resp), nil return pager.NewPageModel(total, resp), nil

View File

@ -1,9 +1,13 @@
package permission package permission
import "github.com/answerdev/answer/internal/schema" import (
"context"
"github.com/answerdev/answer/internal/schema"
)
// TODO: There is currently no permission management // TODO: There is currently no permission management
func GetCommentPermission(userID string, commentCreatorUserID string) ( func GetCommentPermission(ctx context.Context, userID string, commentCreatorUserID string) (
actions []*schema.PermissionMemberAction) { actions []*schema.PermissionMemberAction) {
actions = make([]*schema.PermissionMemberAction, 0) actions = make([]*schema.PermissionMemberAction, 0)
if len(userID) > 0 { if len(userID) > 0 {
@ -31,7 +35,7 @@ func GetCommentPermission(userID string, commentCreatorUserID string) (
return actions return actions
} }
func GetTagPermission(userID string, tagCreatorUserID string) ( func GetTagPermission(ctx context.Context, userID string, tagCreatorUserID string) (
actions []*schema.PermissionMemberAction) { actions []*schema.PermissionMemberAction) {
if userID != tagCreatorUserID { if userID != tagCreatorUserID {
return []*schema.PermissionMemberAction{} return []*schema.PermissionMemberAction{}
@ -50,9 +54,10 @@ func GetTagPermission(userID string, tagCreatorUserID string) (
} }
} }
func GetAnswerPermission(userID string, answerAuthID string) ( func GetAnswerPermission(ctx context.Context, userID string, answerAuthID string, isAdmin bool) (
actions []*schema.PermissionMemberAction) { actions []*schema.PermissionMemberAction) {
actions = make([]*schema.PermissionMemberAction, 0) actions = make([]*schema.PermissionMemberAction, 0)
if !isAdmin {
if len(userID) > 0 { if len(userID) > 0 {
actions = append(actions, &schema.PermissionMemberAction{ actions = append(actions, &schema.PermissionMemberAction{
Action: "report", Action: "report",
@ -63,6 +68,7 @@ func GetAnswerPermission(userID string, answerAuthID string) (
if userID != answerAuthID { if userID != answerAuthID {
return actions return actions
} }
}
actions = append(actions, []*schema.PermissionMemberAction{ actions = append(actions, []*schema.PermissionMemberAction{
{ {
Action: "edit", Action: "edit",
@ -78,9 +84,9 @@ func GetAnswerPermission(userID string, answerAuthID string) (
return actions return actions
} }
func GetQuestionPermission(userID string, questionAuthID string) ( func GetQuestionPermission(ctx context.Context, userID string, questionAuthID string, isAdmin bool) (actions []*schema.PermissionMemberAction) {
actions []*schema.PermissionMemberAction) {
actions = make([]*schema.PermissionMemberAction, 0) actions = make([]*schema.PermissionMemberAction, 0)
if !isAdmin {
if len(userID) > 0 { if len(userID) > 0 {
actions = append(actions, &schema.PermissionMemberAction{ actions = append(actions, &schema.PermissionMemberAction{
Action: "report", Action: "report",
@ -91,6 +97,7 @@ func GetQuestionPermission(userID string, questionAuthID string) (
if userID != questionAuthID { if userID != questionAuthID {
return actions return actions
} }
}
actions = append(actions, []*schema.PermissionMemberAction{ actions = append(actions, []*schema.PermissionMemberAction{
{ {
Action: "edit", Action: "edit",

View File

@ -71,6 +71,12 @@ func (qs *QuestionService) CloseQuestion(ctx context.Context, req *schema.CloseQ
if !has { if !has {
return nil return nil
} }
if !req.IsAdmin {
if questionInfo.UserID != req.UserID {
return errors.BadRequest(reason.QuestionCannotClose)
}
}
questionInfo.Status = entity.QuestionStatusclosed questionInfo.Status = entity.QuestionStatusclosed
err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo) err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo)
if err != nil { if err != nil {
@ -161,7 +167,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Question
log.Error("user IncreaseQuestionCount error", err.Error()) log.Error("user IncreaseQuestionCount error", err.Error())
} }
questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false) questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false, false)
return return
} }
@ -174,15 +180,31 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Remov
if !has { if !has {
return nil return nil
} }
if !req.IsAdmin {
if questionInfo.UserID != req.UserID { if questionInfo.UserID != req.UserID {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.QuestionCannotDeleted)
} }
if questionInfo.AcceptedAnswerID != "" { if questionInfo.AcceptedAnswerID != "0" {
return errors.BadRequest(reason.UnauthorizedError) return errors.BadRequest(reason.QuestionCannotDeleted)
}
if questionInfo.AnswerCount > 1 {
return errors.BadRequest(reason.QuestionCannotDeleted)
}
if questionInfo.AnswerCount == 1 {
answersearch := &entity.AnswerSearch{}
answersearch.QuestionID = req.ID
answerList, _, err := qs.questioncommon.AnswerCommon.Search(ctx, answersearch)
if err != nil {
return err
}
for _, answer := range answerList {
if answer.VoteCount > 0 {
return errors.BadRequest(reason.QuestionCannotDeleted)
}
}
} }
if questionInfo.AnswerCount > 0 {
return errors.BadRequest(reason.UnauthorizedError)
} }
questionInfo.Status = entity.QuestionStatusDeleted questionInfo.Status = entity.QuestionStatusDeleted
@ -223,8 +245,11 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
if !has { if !has {
return return
} }
if !req.IsAdmin {
if dbinfo.UserID != req.UserID { if dbinfo.UserID != req.UserID {
return return questionInfo, errors.BadRequest(reason.QuestionCannotUpdate)
}
} }
//CheckChangeTag //CheckChangeTag
@ -274,12 +299,12 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
return return
} }
questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false) questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false, false)
return return
} }
// GetQuestion get question one // GetQuestion get question one
func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID string, addpv bool) (resp *schema.QuestionInfo, err error) { func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID string, addpv bool, isAdmin bool) (resp *schema.QuestionInfo, err error) {
question, err := qs.questioncommon.Info(ctx, id, loginUserID) question, err := qs.questioncommon.Info(ctx, id, loginUserID)
if err != nil { if err != nil {
return return
@ -291,7 +316,7 @@ func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID stri
} }
} }
question.MemberActions = permission.GetQuestionPermission(loginUserID, question.UserID) question.MemberActions = permission.GetQuestionPermission(ctx, loginUserID, question.UserID, isAdmin)
return question, nil return question, nil
} }
@ -518,7 +543,7 @@ func (qs *QuestionService) SearchByTitleLike(ctx context.Context, title string,
// SimilarQuestion // SimilarQuestion
func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID string, loginUserID string) ([]*schema.QuestionInfo, int64, error) { func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID string, loginUserID string) ([]*schema.QuestionInfo, int64, error) {
list := make([]*schema.QuestionInfo, 0) list := make([]*schema.QuestionInfo, 0)
questionInfo, err := qs.GetQuestion(ctx, questionID, loginUserID, false) questionInfo, err := qs.GetQuestion(ctx, questionID, loginUserID, false, false)
if err != nil { if err != nil {
return list, 0, err return list, 0, err
} }

View File

@ -154,7 +154,7 @@ func (ts *TagService) GetTagInfo(ctx context.Context, req *schema.GetTagInfoReq)
resp.Recommend = tagInfo.Recommend resp.Recommend = tagInfo.Recommend
resp.Reserved = tagInfo.Reserved resp.Reserved = tagInfo.Reserved
resp.IsFollower = ts.checkTagIsFollow(ctx, req.UserID, tagInfo.ID) resp.IsFollower = ts.checkTagIsFollow(ctx, req.UserID, tagInfo.ID)
resp.MemberActions = permission.GetTagPermission(req.UserID, req.UserID) resp.MemberActions = permission.GetTagPermission(ctx, req.UserID, req.UserID)
resp.GetExcerpt() resp.GetExcerpt()
return resp, nil return resp, nil
} }

View File

@ -160,20 +160,10 @@ const routes: RouteNode[] = [
{ {
path: 'users/password-reset', path: 'users/password-reset',
page: 'pages/Users/PasswordReset', page: 'pages/Users/PasswordReset',
guard: async () => {
return guard.activated();
},
}, },
{ {
path: 'users/account-activation', path: 'users/account-activation',
page: 'pages/Users/ActiveEmail', page: 'pages/Users/ActiveEmail',
// guard: async () => {
// const notActivated = guard.notActivated();
// if (notActivated.ok) {
// return notActivated;
// }
// return guard.notLogged();
// },
}, },
{ {
path: 'users/account-activation/success', path: 'users/account-activation/success',