diff options
Diffstat (limited to 'models/token.go')
-rw-r--r-- | models/token.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/models/token.go b/models/token.go index 8bd20a6916..ce3218d8d6 100644 --- a/models/token.go +++ b/models/token.go @@ -78,12 +78,20 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) { } // ListAccessTokens returns a list of access tokens belongs to given user. -func ListAccessTokens(uid int64) ([]*AccessToken, error) { - tokens := make([]*AccessToken, 0, 5) - return tokens, x. +func ListAccessTokens(uid int64, listOptions ListOptions) ([]*AccessToken, error) { + sess := x. Where("uid=?", uid). - Desc("id"). - Find(&tokens) + Desc("id") + + if listOptions.Page == 0 { + sess = listOptions.setSessionPagination(sess) + + tokens := make([]*AccessToken, 0, listOptions.PageSize) + return tokens, sess.Find(&tokens) + } + + tokens := make([]*AccessToken, 0, 5) + return tokens, sess.Find(&tokens) } // UpdateAccessToken updates information of access token. |