Browse Source

models/token: generate bindata and simplify code (#5820)

Unknwon 5 years ago
parent
commit
a04de87584
4 changed files with 119 additions and 121 deletions
  1. 1 1
      gogs.go
  2. 5 7
      models/token.go
  3. 112 112
      pkg/bindata/bindata.go
  4. 1 1
      templates/.VERSION

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"github.com/gogs/gogs/pkg/setting"
 )
 
-const Version = "0.11.94.1003"
+const Version = "0.11.95.1015"
 
 func init() {
 	setting.AppVer = Version

+ 5 - 7
models/token.go

@@ -5,7 +5,6 @@
 package models
 
 import (
-	"fmt"
 	"time"
 
 	"github.com/go-xorm/xorm"
@@ -48,16 +47,15 @@ func (t *AccessToken) AfterSet(colName string, _ xorm.Cell) {
 	}
 }
 
-func isAccessTokenNameExist(uid int64, name string) (bool, error) {
-    return x.Where("uid=?", uid).And("name=?", name).Get(&AccessToken{})
-}
-
 // NewAccessToken creates new access token.
 func NewAccessToken(t *AccessToken) error {
 	t.Sha1 = tool.SHA1(gouuid.NewV4().String())
-	has, err := isAccessTokenNameExist(t.UID, t.Name)
+	has, err := x.Get(&AccessToken{
+		UID:  t.UID,
+		Name: t.Name,
+	})
 	if err != nil {
-		return fmt.Errorf("IsAccessTokenNameExists: %v", err)
+		return err
 	} else if has {
 		return errors.AccessTokenNameAlreadyExist{t.Name}
 	}

File diff suppressed because it is too large
+ 112 - 112
pkg/bindata/bindata.go


+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.11.94.1003
+0.11.95.1015

Some files were not shown because too many files changed in this diff