From 74af7af2e36ad33a0a12549c0c6a7f8345bc688a Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 5 Apr 2026 19:56:16 +0200 Subject: [PATCH] refactor(api_tokens): preserve pre-set OwnerID in Create --- pkg/models/api_tokens.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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