MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / checkSession

Function checkSession

core/init/router/proxy.go:78–95  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

76}
77
78func checkSession(c *gin.Context) bool {
79 psession, err := global.SESSION.Get(c)
80 if err != nil {
81 return false
82 }
83 c.Set(psessionUtils.GinContextSessionUserKey, psession)
84 sessionTimeout, err := baseRepo.NewISettingRepo().GetValueByKey("SessionTimeout")
85 if err != nil {
86 global.LOG.Errorf("get session timeout failed, err: %v", err)
87 return false
88 }
89 lifeTime, _ := strconv.Atoi(sessionTimeout)
90 if _, err := global.SESSION.RefreshIfNeeded(c, psession, global.CONF.Conn.SSL == constant.StatusEnable, lifeTime); err != nil {
91 global.LOG.Warnf("proxy refresh session failed, path=%s, err=%v", c.Request.URL.Path, err)
92 return false
93 }
94 return true
95}
96
97func isLocalAPI(urlPath string) bool {
98 return urlPath == "/api/v2/core/xpack/sync/ssl" || urlPath == "/api/v2/core/xpack/settings/search"

Callers 1

ProxyFunction · 0.70

Calls 4

RefreshIfNeededMethod · 0.80
GetMethod · 0.65
GetValueByKeyMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected