aboutsummaryrefslogtreecommitdiff
path: root/modules/auth
diff options
context:
space:
mode:
Diffstat (limited to 'modules/auth')
7 files changed, 31 insertions, 21 deletions
diff --git a/modules/auth/admin.go b/modules/auth/admin.go
index e2dc0fd2..c82fa781 100644
--- a/modules/auth/admin.go
+++ b/modules/auth/admin.go
@@ -12,6 +12,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
type AdminEditUserForm struct {
@@ -34,7 +35,7 @@ func (f *AdminEditUserForm) Name(field string) string {
return names[field]
}
-func (f *AdminEditUserForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *AdminEditUserForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index 49ace507..2f773491 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -13,6 +13,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
// Web form interface.
@@ -21,7 +22,7 @@ type Form interface {
}
type RegisterForm struct {
- UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
+ UserName string `form:"username" binding:"Required;AlphaDashDot;MaxSize(30)"`
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
RetypePasswd string `form:"retypepasswd"`
@@ -38,7 +39,7 @@ func (f *RegisterForm) Name(field string) string {
return names[field]
}
-func (f *RegisterForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *RegisterForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
@@ -58,7 +59,7 @@ func (f *RegisterForm) Validate(errors *base.BindingErrors, req *http.Request, c
}
type LogInForm struct {
- UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
+ UserName string `form:"username" binding:"Required;MaxSize(35)"`
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
Remember string `form:"remember"`
}
@@ -71,7 +72,7 @@ func (f *LogInForm) Name(field string) string {
return names[field]
}
-func (f *LogInForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *LogInForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
@@ -99,7 +100,7 @@ func getMinMaxSize(field reflect.StructField) string {
return ""
}
-func validate(errors *base.BindingErrors, data base.TmplData, form Form) {
+func validate(errors *binding.BindingErrors, data base.TmplData, form Form) {
typ := reflect.TypeOf(form)
val := reflect.ValueOf(form)
@@ -120,17 +121,19 @@ func validate(errors *base.BindingErrors, data base.TmplData, form Form) {
if err, ok := errors.Fields[field.Name]; ok {
data["Err_"+field.Name] = true
switch err {
- case base.BindingRequireError:
+ case binding.BindingRequireError:
data["ErrorMsg"] = form.Name(field.Name) + " cannot be empty"
- case base.BindingAlphaDashError:
+ case binding.BindingAlphaDashError:
data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) characters"
- case base.BindingMinSizeError:
+ case binding.BindingAlphaDashDotError:
+ data["ErrorMsg"] = form.Name(field.Name) + " must be valid alpha or numeric or dash(-_) or dot characters"
+ case binding.BindingMinSizeError:
data["ErrorMsg"] = form.Name(field.Name) + " must contain at least " + getMinMaxSize(field) + " characters"
- case base.BindingMaxSizeError:
+ case binding.BindingMaxSizeError:
data["ErrorMsg"] = form.Name(field.Name) + " must contain at most " + getMinMaxSize(field) + " characters"
- case base.BindingEmailError:
+ case binding.BindingEmailError:
data["ErrorMsg"] = form.Name(field.Name) + " is not a valid e-mail address"
- case base.BindingUrlError:
+ case binding.BindingUrlError:
data["ErrorMsg"] = form.Name(field.Name) + " is not a valid URL"
default:
data["ErrorMsg"] = "Unknown error: " + err
@@ -175,7 +178,7 @@ type InstallForm struct {
RunUser string `form:"run_user"`
Domain string `form:"domain"`
AppUrl string `form:"app_url"`
- AdminName string `form:"admin_name" binding:"Required"`
+ AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"`
AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(30)"`
AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"`
SmtpHost string `form:"smtp_host"`
@@ -195,7 +198,7 @@ func (f *InstallForm) Name(field string) string {
return names[field]
}
-func (f *InstallForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *InstallForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
diff --git a/modules/auth/issue.go b/modules/auth/issue.go
index f73ddc74..85be12d2 100644
--- a/modules/auth/issue.go
+++ b/modules/auth/issue.go
@@ -12,6 +12,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
type CreateIssueForm struct {
@@ -29,7 +30,7 @@ func (f *CreateIssueForm) Name(field string) string {
return names[field]
}
-func (f *CreateIssueForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *CreateIssueForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
diff --git a/modules/auth/release.go b/modules/auth/release.go
index a29028e0..9855c303 100644
--- a/modules/auth/release.go
+++ b/modules/auth/release.go
@@ -12,6 +12,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
type NewReleaseForm struct {
@@ -30,7 +31,7 @@ func (f *NewReleaseForm) Name(field string) string {
return names[field]
}
-func (f *NewReleaseForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *NewReleaseForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
diff --git a/modules/auth/repo.go b/modules/auth/repo.go
index f67fbf67..e61e8202 100644
--- a/modules/auth/repo.go
+++ b/modules/auth/repo.go
@@ -12,6 +12,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
type CreateRepoForm struct {
@@ -31,7 +32,7 @@ func (f *CreateRepoForm) Name(field string) string {
return names[field]
}
-func (f *CreateRepoForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *CreateRepoForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
@@ -69,7 +70,7 @@ func (f *MigrateRepoForm) Name(field string) string {
return names[field]
}
-func (f *MigrateRepoForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *MigrateRepoForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
diff --git a/modules/auth/setting.go b/modules/auth/setting.go
index 7cee00de..3316d7b9 100644
--- a/modules/auth/setting.go
+++ b/modules/auth/setting.go
@@ -13,6 +13,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
type AddSSHKeyForm struct {
@@ -28,7 +29,7 @@ func (f *AddSSHKeyForm) Name(field string) string {
return names[field]
}
-func (f *AddSSHKeyForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *AddSSHKeyForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
AssignForm(f, data)
diff --git a/modules/auth/user.go b/modules/auth/user.go
index 97389422..0e591398 100644
--- a/modules/auth/user.go
+++ b/modules/auth/user.go
@@ -15,6 +15,7 @@ import (
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware/binding"
)
// SignedInId returns the id of signed in user.
@@ -75,6 +76,7 @@ type FeedsForm struct {
type UpdateProfileForm struct {
UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
+ FullName string `form:"fullname" binding:"MaxSize(40)"`
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
Website string `form:"website" binding:"MaxSize(50)"`
Location string `form:"location" binding:"MaxSize(50)"`
@@ -92,7 +94,7 @@ func (f *UpdateProfileForm) Name(field string) string {
return names[field]
}
-func (f *UpdateProfileForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *UpdateProfileForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}
@@ -125,7 +127,7 @@ func (f *UpdatePasswdForm) Name(field string) string {
return names[field]
}
-func (f *UpdatePasswdForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+func (f *UpdatePasswdForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
if req.Method == "GET" || errors.Count() == 0 {
return
}