diff options
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)) |