MCPcopy
hub / github.com/apache/answer / GetUserIsAdminModerator

Function GetUserIsAdminModerator

internal/base/middleware/auth.go:300–313  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

298}
299
300func GetUserIsAdminModerator(ctx *gin.Context) (isAdminModerator bool) {
301 userInfo, exist := ctx.Get(ctxUUIDKey)
302 if !exist {
303 return false
304 }
305 u, ok := userInfo.(*entity.UserCacheInfo)
306 if !ok {
307 return false
308 }
309 if u.RoleID == role.RoleAdminID || u.RoleID == role.RoleModeratorID {
310 return true
311 }
312 return false
313}
314
315func GetLoginUserIDInt64FromContext(ctx *gin.Context) (userID int64) {
316 userIDStr := GetLoginUserIDFromContext(ctx)

Callers 15

EditUserProfileMethod · 0.92
GetUnreviewedPostPageMethod · 0.92
UpdateReviewMethod · 0.92
GetTagInfoMethod · 0.92
MergeTagMethod · 0.92
AddCommentMethod · 0.92
RemoveCommentMethod · 0.92
GetCommentWithPageMethod · 0.92
GetCommentMethod · 0.92
SearchMethod · 0.92
VoteUpMethod · 0.92
VoteDownMethod · 0.92

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected