mirror of https://github.com/gogs/gogs.git
models/token: generate bindata and simplify code (#5820)
parent
ffbb0f6a60
commit
a04de87584
2
gogs.go
2
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 +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 one or more lines are too long
|
@ -1 +1 @@
|
|||
0.11.94.1003
|
||||
0.11.95.1015
|
||||
|
|
Loading…
Reference in New Issue