diff --git a/handlers/type.go b/handlers/type.go index 7777248..46508a5 100644 --- a/handlers/type.go +++ b/handlers/type.go @@ -4,23 +4,23 @@ package handlers type userSignin struct { - Username string `form:"username" json:"username" validate:"required,username"` - Password string `form:"password" json:"password" validate:"required,password"` + Username string `form:"username" json:"username" validate:"required,username,gte=2"` + Password string `form:"password" json:"password" validate:"required,password,gte=12"` } type userSignup struct { - Username string `form:"username" json:"username" validate:"required,username"` + Username string `form:"username" json:"username" validate:"required,username,gte=2"` Email string `form:"email" json:"email" validate:"required,email"` - Password string `form:"password" json:"password" validate:"required,password"` + Password string `form:"password" json:"password" validate:"required,password,gte=20"` } // this struct is also used on update by admins, which is why the password fields are omitempty. // when users finish setting up, admins can no longer change their passwords. type userCreate struct { - Username string `form:"username" json:"username" validate:"required,username"` + Username string `form:"username" json:"username" validate:"required,username,gte=2"` Email string `form:"email" json:"email" validate:"required,email"` - Password string `form:"password" json:"password" validate:"omitempty,password"` - RepeatPassword string `form:"repeatPassword" json:"repeatPassword" validate:"omitempty,repeatPassword"` + Password string `form:"password" json:"password" validate:"omitempty,password,gte=20"` + RepeatPassword string `form:"repeatPassword" json:"repeatPassword" validate:"omitempty,repeatPassword,gte=20"` IsAdmin bool `form:"isAdmin" json:"isAdmin" validate:"required,isAdmin"` IsActive *bool `form:"isActive" json:"isActive" validate:"omitempty,isActive"` } @@ -30,13 +30,13 @@ type userID struct { } type initPasswordChange struct { - NewPassword string `form:"new-password" validate:"required,new-password"` + NewPassword string `form:"new-password" validate:"required,new-password,gte=20"` } type hibpSearch struct { - Account string `form:"search" validate:"required,search"` + Account string `form:"search" validate:"required,search,gt=2"` } type hibpBreachDetail struct { - BreachName string `param:"name" validate:"required,name"` + BreachName string `param:"name" validate:"required,name,gt=0"` } diff --git a/templates/manage/user-new.tmpl b/templates/manage/user-new.tmpl index 7d0d33b..69bc9e6 100644 --- a/templates/manage/user-new.tmpl +++ b/templates/manage/user-new.tmpl @@ -37,13 +37,13 @@ {{ template "svg-password.tmpl" }} - +