diff --git a/controllers/verification.go b/controllers/verification.go index 1757ad10..f86b7914 100644 --- a/controllers/verification.go +++ b/controllers/verification.go @@ -40,8 +40,7 @@ func (c *ApiController) SendVerificationCode() { checkType := c.Ctx.Request.Form.Get("checkType") checkId := c.Ctx.Request.Form.Get("checkId") checkKey := c.Ctx.Request.Form.Get("checkKey") - remoteAddr := c.Ctx.Request.RemoteAddr - remoteAddr = remoteAddr[:strings.LastIndex(remoteAddr, ":")] + remoteAddr := util.GetIPFromRequest(c.Ctx.Request) 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.") diff --git a/util/log.go b/util/log.go index 4a8ff8ed..be5f87de 100644 --- a/util/log.go +++ b/util/log.go @@ -44,7 +44,7 @@ func GetIPInfo(clientIP string) string { return res } -func getIPFromRequest(req *http.Request) string { +func GetIPFromRequest(req *http.Request) string { clientIP := req.Header.Get("x-forwarded-for") if clientIP == "" { ipPort := strings.Split(req.RemoteAddr, ":") @@ -62,11 +62,11 @@ func getIPFromRequest(req *http.Request) string { } 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...) } 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...) } diff --git a/util/record.go b/util/record.go index 2b0f9fcb..5ea72b8c 100644 --- a/util/record.go +++ b/util/record.go @@ -30,7 +30,7 @@ type Record struct { } func Records(ctx *context.Context) *Record { - ip := strings.Replace(getIPFromRequest(ctx.Request), ": ", "", -1) + ip := strings.Replace(GetIPFromRequest(ctx.Request), ": ", "", -1) currenttime := GetCurrentTime() requesturi := ctx.Request.RequestURI action := strings.Replace(ctx.Request.URL.Path, "/api/", "", -1) diff --git a/web/src/auth/SignupPage.js b/web/src/auth/SignupPage.js index 94b4e967..90fafd5e 100644 --- a/web/src/auth/SignupPage.js +++ b/web/src/auth/SignupPage.js @@ -423,7 +423,7 @@ class SignupPage extends React.Component { // , ]} > -
+ ) }