aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-02-17 18:38:50 -0500
committerUnknown <joe2010xtmf@163.com>2014-02-17 18:38:50 -0500
commit3eb1ab9e8b12a80096d6b10a7f0a398aec8d8172 (patch)
treef37d6bc5c6d006d97e4fd4f3a3a9891eb98c5156 /models
parent5da2ad743567297b965b06a8e75ab37d308b215c (diff)
Add UI for register user
Diffstat (limited to 'models')
-rw-r--r--models/access.go17
-rw-r--r--models/user.go4
2 files changed, 17 insertions, 4 deletions
diff --git a/models/access.go b/models/access.go
index 11bb360a..ea5cbfaa 100644
--- a/models/access.go
+++ b/models/access.go
@@ -1,3 +1,7 @@
+// 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 models
import (
@@ -6,8 +10,8 @@ import (
)
const (
- Readable = iota + 1
- Writable
+ AU_READABLE = iota + 1
+ AU_WRITABLE
)
type Access struct {
@@ -24,6 +28,11 @@ func AddAccess(access *Access) error {
}
// if one user can read or write one repository
-func HasAccess(userName, repoName, mode string) (bool, error) {
- return orm.Get(&Access{0, strings.ToLower(userName), strings.ToLower(repoName), mode})
+func HasAccess(userName, repoName string, mode int) (bool, error) {
+ return orm.Get(&Access{
+ Id: 0,
+ UserName: strings.ToLower(userName),
+ RepoName: strings.ToLower(repoName),
+ Mode: mode,
+ })
}
diff --git a/models/user.go b/models/user.go
index 6ea329c5..44dadb9a 100644
--- a/models/user.go
+++ b/models/user.go
@@ -98,6 +98,10 @@ func RegisterUser(user *User) (err error) {
if err = validateUser(user.Name); err != nil {
return err
}
+ user.LowerName = strings.ToLower(user.Name)
+ // TODO: generate Avatar address.
+ user.Created = time.Now()
+ user.Updated = time.Now()
_, err = orm.Insert(user)
return err
}