go-common/app/admin/main/mcn/server/http/authority.go

26 lines
524 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package http
import (
"net/http"
"go-common/library/ecode"
bm "go-common/library/net/http/blademaster"
)
// check username and dashboard sessionid
func checkCookie(c *bm.Context) (username, sid string, err error) {
var r = c.Request
var name *http.Cookie
if name, err = r.Cookie("username"); err == nil {
username = name.Value
}
var session *http.Cookie
if session, err = r.Cookie("_AJSESSIONID"); err == nil {
sid = session.Value
}
if username == "" || sid == "" {
err = ecode.Unauthorized
}
return
}