authority.go 524 B

12345678910111213141516171819202122232425
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // check username and dashboard sessionid
  8. func checkCookie(c *bm.Context) (username, sid string, err error) {
  9. var r = c.Request
  10. var name *http.Cookie
  11. if name, err = r.Cookie("username"); err == nil {
  12. username = name.Value
  13. }
  14. var session *http.Cookie
  15. if session, err = r.Cookie("_AJSESSIONID"); err == nil {
  16. sid = session.Value
  17. }
  18. if username == "" || sid == "" {
  19. err = ecode.Unauthorized
  20. }
  21. return
  22. }