aboutsummaryrefslogtreecommitdiff
path: root/modules/auth
diff options
context:
space:
mode:
Diffstat (limited to 'modules/auth')
-rw-r--r--modules/auth/auth.go1
-rw-r--r--modules/auth/issue.go54
-rw-r--r--modules/auth/user.go11
3 files changed, 61 insertions, 5 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index 0e871688..2e0555f6 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -61,6 +61,7 @@ func (f *RegisterForm) Validate(errors *binding.Errors, req *http.Request, conte
type LogInForm struct {
UserName string `form:"username" binding:"Required;AlphaDash;MaxSize(30)"`
Password string `form:"passwd" binding:"Required;MinSize(6);MaxSize(30)"`
+ Remember string `form:"remember"`
}
func (f *LogInForm) Name(field string) string {
diff --git a/modules/auth/issue.go b/modules/auth/issue.go
new file mode 100644
index 00000000..e2b1f9f2
--- /dev/null
+++ b/modules/auth/issue.go
@@ -0,0 +1,54 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package auth
+
+import (
+ "net/http"
+ "reflect"
+
+ "github.com/codegangsta/martini"
+
+ "github.com/gogits/binding"
+
+ "github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/log"
+)
+
+type CreateIssueForm struct {
+ IssueName string `form:"name" binding:"Required;MaxSize(50)"`
+ RepoId int64 `form:"repoid" binding:"Required"`
+ MilestoneId int64 `form:"milestoneid" binding:"Required"`
+ AssigneeId int64 `form:"assigneeid"`
+ Labels string `form:"labels"`
+ Content string `form:"content"`
+}
+
+func (f *CreateIssueForm) Name(field string) string {
+ names := map[string]string{
+ "IssueName": "Issue name",
+ "RepoId": "Repository ID",
+ "MilestoneId": "Milestone ID",
+ }
+ return names[field]
+}
+
+func (f *CreateIssueForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
+ if req.Method == "GET" || errors.Count() == 0 {
+ return
+ }
+
+ data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
+ data["HasError"] = true
+ AssignForm(f, data)
+
+ if len(errors.Overall) > 0 {
+ for _, err := range errors.Overall {
+ log.Error("CreateIssueForm.Validate: %v", err)
+ }
+ return
+ }
+
+ validate(errors, data, f)
+}
diff --git a/modules/auth/user.go b/modules/auth/user.go
index f8d8f661..cb8db1b2 100644
--- a/modules/auth/user.go
+++ b/modules/auth/user.go
@@ -9,7 +9,8 @@ import (
"reflect"
"github.com/codegangsta/martini"
- "github.com/martini-contrib/sessions"
+
+ "github.com/gogits/session"
"github.com/gogits/binding"
@@ -19,7 +20,7 @@ import (
)
// SignedInId returns the id of signed in user.
-func SignedInId(session sessions.Session) int64 {
+func SignedInId(session session.SessionStore) int64 {
userId := session.Get("userId")
if userId == nil {
return 0
@@ -34,7 +35,7 @@ func SignedInId(session sessions.Session) int64 {
}
// SignedInName returns the name of signed in user.
-func SignedInName(session sessions.Session) string {
+func SignedInName(session session.SessionStore) string {
userName := session.Get("userName")
if userName == nil {
return ""
@@ -46,7 +47,7 @@ func SignedInName(session sessions.Session) string {
}
// SignedInUser returns the user object of signed user.
-func SignedInUser(session sessions.Session) *models.User {
+func SignedInUser(session session.SessionStore) *models.User {
id := SignedInId(session)
if id <= 0 {
return nil
@@ -61,7 +62,7 @@ func SignedInUser(session sessions.Session) *models.User {
}
// IsSignedIn check if any user has signed in.
-func IsSignedIn(session sessions.Session) bool {
+func IsSignedIn(session session.SessionStore) bool {
return SignedInId(session) > 0
}