add signup ip support

This commit is contained in:
2023-02-18 15:20:24 +05:30
parent ae4397250e
commit bba3d72d95
2 changed files with 9 additions and 1 deletions

View File

@@ -11,7 +11,13 @@ import (
// SignupPage is the signup page handler
func SignupPage(c *fiber.Ctx) error {
SignupIP, SignupIPExists := os.LookupEnv("PUBLAPI_SIGNUP_IP")
if SignupIPExists == true {
if c.IP() != SignupIP {
log.Info("Request made from invalid IP: ", c.IP())
return c.SendStatus(fiber.StatusForbidden)
}
}
username := c.FormValue("username")
email := c.FormValue("email")
ssh := c.FormValue("ssh")