Skip to content

Commit

Permalink
fix: redirect to login page while ip mismatched
Browse files Browse the repository at this point in the history
  • Loading branch information
YenchangChan committed Nov 6, 2022
1 parent 507568f commit 98b4396
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions server/server.go
Expand Up @@ -3,14 +3,15 @@ package server
import (
"context"
"fmt"
"github.com/go-errors/errors"
jsoniter "github.com/json-iterator/go"
"io"
"net/http"
"os"
"runtime/debug"
"time"

"github.com/go-errors/errors"
jsoniter "github.com/json-iterator/go"

"github.com/patrickmn/go-cache"

static "github.com/choidamdam/gin-static-pkger"
Expand All @@ -33,9 +34,9 @@ var json = jsoniter.ConfigCompatibleWithStandardLibrary
const ENV_CKMAN_SWAGGER string = "ENV_CKMAN_SWAGGER"

type ApiServer struct {
config *config.CKManConfig
svr *http.Server
signal chan os.Signal
config *config.CKManConfig
svr *http.Server
signal chan os.Signal
}

func NewApiServer(config *config.CKManConfig, signal chan os.Signal) *ApiServer {
Expand Down Expand Up @@ -229,7 +230,7 @@ func ginJWTAuth() gin.HandlerFunc {
// Verify client ip
if claims.ClientIP != c.ClientIP() {
err := errors.Errorf("cliams.ClientIP: %s, c.ClientIP:%s", claims.ClientIP, c.ClientIP())
model.WrapMsg(c, model.JWT_TOKEN_IP_MISMATCH, err)
model.WrapMsg(c, model.JWT_TOKEN_EXPIRED, err)
c.Abort()
return
}
Expand Down

0 comments on commit 98b4396

Please sign in to comment.