mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 18:02:55 +08:00
Get real IP for verification log.
This commit is contained in:
@@ -40,8 +40,7 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
checkType := c.Ctx.Request.Form.Get("checkType")
|
checkType := c.Ctx.Request.Form.Get("checkType")
|
||||||
checkId := c.Ctx.Request.Form.Get("checkId")
|
checkId := c.Ctx.Request.Form.Get("checkId")
|
||||||
checkKey := c.Ctx.Request.Form.Get("checkKey")
|
checkKey := c.Ctx.Request.Form.Get("checkKey")
|
||||||
remoteAddr := c.Ctx.Request.RemoteAddr
|
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
|
||||||
remoteAddr = remoteAddr[:strings.LastIndex(remoteAddr, ":")]
|
|
||||||
|
|
||||||
if len(destType) == 0 || len(dest) == 0 || len(orgId) == 0 || strings.Index(orgId, "/") < 0 || len(checkType) == 0 || len(checkId) == 0 || len(checkKey) == 0 {
|
if len(destType) == 0 || len(dest) == 0 || len(orgId) == 0 || strings.Index(orgId, "/") < 0 || len(checkType) == 0 || len(checkId) == 0 || len(checkKey) == 0 {
|
||||||
c.ResponseError("Missing parameter.")
|
c.ResponseError("Missing parameter.")
|
||||||
|
@@ -44,7 +44,7 @@ func GetIPInfo(clientIP string) string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIPFromRequest(req *http.Request) string {
|
func GetIPFromRequest(req *http.Request) string {
|
||||||
clientIP := req.Header.Get("x-forwarded-for")
|
clientIP := req.Header.Get("x-forwarded-for")
|
||||||
if clientIP == "" {
|
if clientIP == "" {
|
||||||
ipPort := strings.Split(req.RemoteAddr, ":")
|
ipPort := strings.Split(req.RemoteAddr, ":")
|
||||||
@@ -62,11 +62,11 @@ func getIPFromRequest(req *http.Request) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LogInfo(ctx *context.Context, f string, v ...interface{}) {
|
func LogInfo(ctx *context.Context, f string, v ...interface{}) {
|
||||||
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
|
ipString := fmt.Sprintf("(%s) ", GetIPFromRequest(ctx.Request))
|
||||||
logs.Info(ipString+f, v...)
|
logs.Info(ipString+f, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogWarning(ctx *context.Context, f string, v ...interface{}) {
|
func LogWarning(ctx *context.Context, f string, v ...interface{}) {
|
||||||
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
|
ipString := fmt.Sprintf("(%s) ", GetIPFromRequest(ctx.Request))
|
||||||
logs.Warning(ipString+f, v...)
|
logs.Warning(ipString+f, v...)
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ type Record struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Records(ctx *context.Context) *Record {
|
func Records(ctx *context.Context) *Record {
|
||||||
ip := strings.Replace(getIPFromRequest(ctx.Request), ": ", "", -1)
|
ip := strings.Replace(GetIPFromRequest(ctx.Request), ": ", "", -1)
|
||||||
currenttime := GetCurrentTime()
|
currenttime := GetCurrentTime()
|
||||||
requesturi := ctx.Request.RequestURI
|
requesturi := ctx.Request.RequestURI
|
||||||
action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1)
|
action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1)
|
||||||
|
@@ -423,7 +423,7 @@ class SignupPage extends React.Component {
|
|||||||
// </Button>,
|
// </Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div dangerouslySetInnerHTML={{__html: this.state.application.termsOfUse}} />
|
<div dangerouslySetInnerHTML={{__html: this.state.application?.termsOfUse}} />
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user