ocr增加
This commit is contained in:
parent
af726fbcfb
commit
0e33c2ad9d
@ -295,11 +295,14 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
cookie, err := req.Cookie(that.Config.GetString("sessionName"))
|
cookie, err := req.Cookie(that.Config.GetString("sessionName"))
|
||||||
sessionId := Md5(strconv.Itoa(Rand(10)))
|
sessionId := Md5(strconv.Itoa(Rand(10)))
|
||||||
token := req.FormValue("token")
|
token := req.FormValue("token")
|
||||||
|
if len(token) != 32 {
|
||||||
|
token = req.Header.Get("Authorization")
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil || (len(token) == 32 && cookie.Value != token) {
|
if len(token) == 32 && cookie.Value != token {
|
||||||
if len(token) == 32 {
|
sessionId = token
|
||||||
sessionId = token
|
} else {
|
||||||
}
|
sessionId = cookie.Value
|
||||||
//没有跨域设置
|
//没有跨域设置
|
||||||
if that.Config.GetString("crossDomain") == "" {
|
if that.Config.GetString("crossDomain") == "" {
|
||||||
http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId, Path: "/"})
|
http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId, Path: "/"})
|
||||||
@ -307,8 +310,7 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
//跨域允许需要设置cookie的允许跨域https才有效果
|
//跨域允许需要设置cookie的允许跨域https才有效果
|
||||||
w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; Path=/; SameSite=None; Secure")
|
w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; Path=/; SameSite=None; Secure")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sessionId = cookie.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unescapeUrl, err := url.QueryUnescape(req.RequestURI)
|
unescapeUrl, err := url.QueryUnescape(req.RequestURI)
|
||||||
|
Loading…
Reference in New Issue
Block a user