MCPcopy
hub / github.com/ccfos/nightingale / user

Method user

center/router/router_mw.go:157–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155}
156
157func (rt *Router) user() gin.HandlerFunc {
158 return func(c *gin.Context) {
159 username := c.MustGet("username").(string)
160
161 user, err := models.UserGetByUsername(rt.Ctx, username)
162 if err != nil {
163 ginx.Bomb(http.StatusUnauthorized, "unauthorized")
164 }
165
166 if user == nil {
167 ginx.Bomb(http.StatusUnauthorized, "unauthorized")
168 }
169
170 c.Set("user", user)
171 c.Set("isadmin", user.IsAdmin())
172 // Update user.LastActiveTime
173 rt.UserCache.SetLastActiveTime(user.Id, time.Now().Unix())
174 c.Next()
175 }
176}
177
178func (rt *Router) userGroupWrite() gin.HandlerFunc {
179 return func(c *gin.Context) {

Callers 5

ConfigMethod · 0.95
UserMethod · 0.95
alertHisEventGetMethod · 0.95
alertCurEventGetMethod · 0.95
boardGetMethod · 0.95

Calls 4

UserGetByUsernameFunction · 0.92
IsAdminMethod · 0.80
SetLastActiveTimeMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected