diff options
author | Christopher Brickley <brickley@gmail.com> | 2015-01-08 09:16:38 -0500 |
---|---|---|
committer | Christopher Brickley <brickley@gmail.com> | 2015-01-08 09:30:22 -0500 |
commit | d0827e5d5ebc8713e7ba40f560617c3306007ed7 (patch) | |
tree | bd8edf02b44adc35c96ba1353fcce92800f956dc /models/token.go | |
parent | bb26285a12f90a4331053169bf580cc766bc6add (diff) | |
download | gitea-d0827e5d5ebc8713e7ba40f560617c3306007ed7.tar.gz gitea-d0827e5d5ebc8713e7ba40f560617c3306007ed7.zip |
allow http push by token - #842
Diffstat (limited to 'models/token.go')
-rw-r--r-- | models/token.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/token.go b/models/token.go index 909d05e072..9ad2d05174 100644 --- a/models/token.go +++ b/models/token.go @@ -62,6 +62,21 @@ func ListAccessTokens(uid int64) ([]*AccessToken, error) { return tokens, nil } +// ListAllAccessTokens returns all access tokens +func ListAllAccessTokens() ([]*AccessToken, error) { + tokens := make([]*AccessToken, 0, 5) + err := x.Desc("id").Find(&tokens) + if err != nil { + return nil, err + } + + for _, t := range tokens { + t.HasUsed = t.Updated.After(t.Created) + t.HasRecentActivity = t.Updated.Add(7 * 24 * time.Hour).After(time.Now()) + } + return tokens, nil +} + // DeleteAccessTokenById deletes access token by given ID. func DeleteAccessTokenById(id int64) error { _, err := x.Id(id).Delete(new(AccessToken)) |