session consumer query함수 리턴 값의 애매함을 제거
This commit is contained in:
@ -683,18 +683,13 @@ func (ws *WebsocketHandler) upgrade_nosession(w http.ResponseWriter, r *http.Req
|
||||
accid := primitive.ObjectID(*raw)
|
||||
|
||||
sk := r.Header.Get("AS-X-SESSION")
|
||||
authinfo, err := ws.sessionConsumer.Query(sk)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if authinfo.Account != accid {
|
||||
authinfo := ws.sessionConsumer.Query(sk)
|
||||
if !authinfo.Valid() {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if authinfo.Invalidated() {
|
||||
if authinfo.Account != accid {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
@ -737,19 +732,8 @@ func (ws *WebsocketHandler) upgrade(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
authinfo, err := ws.sessionConsumer.Query(sk)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
logger.Error("authorize query failed :", err)
|
||||
return
|
||||
}
|
||||
|
||||
if authinfo.Account.IsZero() {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if authinfo.Invalidated() {
|
||||
authinfo := ws.sessionConsumer.Query(sk)
|
||||
if !authinfo.Valid() {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
@ -305,10 +305,12 @@ func (ws *websocketPeerHandler[T]) upgrade_noauth(w http.ResponseWriter, r *http
|
||||
sk := r.Header.Get("AS-X-SESSION")
|
||||
var accid primitive.ObjectID
|
||||
if len(sk) > 0 {
|
||||
authinfo, err := ws.sessionConsumer.Query(sk)
|
||||
if err == nil {
|
||||
accid = authinfo.Account
|
||||
authinfo := ws.sessionConsumer.Query(sk)
|
||||
if !authinfo.Valid() {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
accid = authinfo.Account
|
||||
}
|
||||
|
||||
if accid.IsZero() {
|
||||
@ -363,14 +365,8 @@ func (ws *websocketPeerHandler[T]) upgrade(w http.ResponseWriter, r *http.Reques
|
||||
}()
|
||||
|
||||
sk := r.Header.Get("AS-X-SESSION")
|
||||
authinfo, err := ws.sessionConsumer.Query(sk)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
logger.Error("authorize query failed :", err)
|
||||
return
|
||||
}
|
||||
|
||||
if authinfo.Account.IsZero() || authinfo.Invalidated() {
|
||||
authinfo := ws.sessionConsumer.Query(sk)
|
||||
if !authinfo.Valid() {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user