aboutsummaryrefslogtreecommitdiffstats
path: root/models/token.go
diff options
context:
space:
mode:
authorChristopher Brickley <brickley@gmail.com>2015-01-08 09:16:38 -0500
committerChristopher Brickley <brickley@gmail.com>2015-01-08 09:30:22 -0500
commitd0827e5d5ebc8713e7ba40f560617c3306007ed7 (patch)
treebd8edf02b44adc35c96ba1353fcce92800f956dc /models/token.go
parentbb26285a12f90a4331053169bf580cc766bc6add (diff)
downloadgitea-d0827e5d5ebc8713e7ba40f560617c3306007ed7.tar.gz
gitea-d0827e5d5ebc8713e7ba40f560617c3306007ed7.zip
allow http push by token - #842
Diffstat (limited to 'models/token.go')
-rw-r--r--models/token.go15
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))