fix(sql): do not check of affected rows bacause it can return incorrect number

This commit is contained in:
fiftin 2024-03-31 12:34:05 +02:00
parent 38bb36736c
commit ec036fd0c2
3 changed files with 3 additions and 15 deletions

View File

@ -61,16 +61,6 @@ func validateMutationResult(res sql.Result, err error) error {
return err
}
affected, err := res.RowsAffected()
if err != nil {
return err
}
if affected == 0 {
return db.ErrNotFound
}
return nil
}

View File

@ -27,10 +27,8 @@ func (d *SqlDb) GetAPIToken(tokenID string) (token db.APIToken, err error) {
return
}
func (d *SqlDb) ExpireAPIToken(userID int, tokenID string) (err error) {
res, err := d.exec("update user__token set expired=true where id=? and user_id=?", tokenID, userID)
return validateMutationResult(res, err)
func (d *SqlDb) ExpireAPIToken(userID int, tokenID string) error {
return validateMutationResult(d.exec("update user__token set expired=true where id=? and user_id=?", tokenID, userID))
}
func (d *SqlDb) DeleteAPIToken(userID int, tokenID string) (err error) {

View File

@ -73,7 +73,7 @@
v-model="item.ssh.private_key"
:label="$t('privateKey')"
:disabled="formSaving || !canEditSecrets"
:rules="[v => !!v || $t('private_key_required')]"
:rules="[v => !canEditSecrets || !!v || $t('private_key_required')]"
v-if="item.type === 'ssh'"
/>