Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ee213c

Browse files
committed
黑名单 IP 不让注册新账号
1 parent ec060df commit 8ee213c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

http/controller/account.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ func (self AccountController) Register(ctx echo.Context) error {
5353
return ctx.Redirect(http.StatusSeeOther, "/")
5454
}
5555

56+
ip := goutils.RemoteIp(Request(ctx))
57+
if logic.DefaultRisk.IsBlackIP(ip) {
58+
return ctx.HTML(http.StatusForbidden, `禁止访问`)
59+
}
60+
5661
registerTpl := "register.html"
5762
username := ctx.FormValue("username")
5863
// 请求注册页面

0 commit comments

Comments
 (0)