mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 19:22:46 +08:00
WsVerifyToken
This commit is contained in:
parent
e98d17b1b7
commit
7d69e35dcf
19
pkg/apiresp/http.go
Normal file
19
pkg/apiresp/http.go
Normal file
@ -0,0 +1,19 @@
|
||||
package apiresp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func HttpError(w http.ResponseWriter, err error) {
|
||||
data, err := json.Marshal(ParseError(err))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = data
|
||||
|
||||
}
|
||||
|
||||
func HttpSuccess(w http.ResponseWriter, data any) {
|
||||
|
||||
}
|
@ -89,15 +89,15 @@ func IsManagerUserID(opUserID string) bool {
|
||||
return utils.IsContain(opUserID, config.Config.Manager.AppManagerUid)
|
||||
}
|
||||
func WsVerifyToken(token, userID, platformID string) error {
|
||||
claim, err := GetClaimFromToken(token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if claim.UID != userID {
|
||||
return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token uid %s != userID %s", claim.UID, userID))
|
||||
}
|
||||
if claim.Platform != platformID {
|
||||
return errs.ErrInternalServer.Wrap(fmt.Sprintf("token platform %s != platformID %s", claim.Platform, platformID))
|
||||
}
|
||||
//claim, err := GetClaimFromToken(token)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//if claim.UID != userID {
|
||||
// return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token uid %s != userID %s", claim.UID, userID))
|
||||
//}
|
||||
//if claim.Platform != platformID {
|
||||
// return errs.ErrInternalServer.Wrap(fmt.Sprintf("token platform %s != platformID %s", claim.Platform, platformID))
|
||||
//}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user