diff --git a/pkg/models/api_tokens.go b/pkg/models/api_tokens.go index b432b235c..80a5a10a4 100644 --- a/pkg/models/api_tokens.go +++ b/pkg/models/api_tokens.go @@ -101,7 +101,9 @@ func (t *APIToken) Create(s *xorm.Session, a web.Auth) (err error) { t.TokenHash = HashToken(t.Token, t.TokenSalt) t.TokenLastEight = t.Token[len(t.Token)-8:] - t.OwnerID = a.GetID() + if t.OwnerID == 0 { + t.OwnerID = a.GetID() + } if err := PermissionsAreValid(t.APIPermissions); err != nil { return err