summaryrefslogtreecommitdiffstats
path: root/models/token.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/token.go')
-rw-r--r--models/token.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/models/token.go b/models/token.go
index 7ad9d41676..71a9f0975f 100644
--- a/models/token.go
+++ b/models/token.go
@@ -77,6 +77,11 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
return nil, ErrAccessTokenNotExist{token}
}
+// AccessTokenByNameExists checks if a token name has been used already by a user.
+func AccessTokenByNameExists(token *AccessToken) (bool, error) {
+ return x.Table("access_token").Where("name = ?", token.Name).And("uid = ?", token.UID).Exist()
+}
+
// ListAccessTokens returns a list of access tokens belongs to given user.
func ListAccessTokens(uid int64, listOptions ListOptions) ([]*AccessToken, error) {
sess := x.