refactor(api_tokens): preserve pre-set OwnerID in Create

This commit is contained in:
kolaente 2026-04-05 19:56:16 +02:00 committed by kolaente
parent 2e6bcec72a
commit 74af7af2e3
1 changed files with 3 additions and 1 deletions

View File

@ -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