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"
|
"github.com/gogs/gogs/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Version = "0.11.94.1003"
|
const Version = "0.11.95.1015"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = Version
|
setting.AppVer = Version
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-xorm/xorm"
|
"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.
|
// NewAccessToken creates new access token.
|
||||||
func NewAccessToken(t *AccessToken) error {
|
func NewAccessToken(t *AccessToken) error {
|
||||||
t.Sha1 = tool.SHA1(gouuid.NewV4().String())
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("IsAccessTokenNameExists: %v", err)
|
return err
|
||||||
} else if has {
|
} else if has {
|
||||||
return errors.AccessTokenNameAlreadyExist{t.Name}
|
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