Fix SSH pubkey detection

This commit is contained in:
Thomas Miceli
2023-05-01 02:55:34 +02:00
parent 713b5d623e
commit 58d40e211f
6 changed files with 21 additions and 28 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ func GetSSHKeyByID(sshKeyId uint) (*SSHKey, error) {
return sshKey, err
}
func GetSSHKeyByContent(sshKeyContent string) (*SSHKey, error) {
func SSHKeyDoesExists(sshKeyContent string) (*SSHKey, error) {
sshKey := new(SSHKey)
err := db.
Where("content like ?", sshKeyContent+"%").
@@ -65,9 +65,9 @@ func (sshKey *SSHKey) Delete() error {
return db.Delete(&sshKey).Error
}
func SSHKeyLastUsedNow(sshKeyID uint) error {
func SSHKeyLastUsedNow(sshKeyContent string) error {
return db.Model(&SSHKey{}).
Where("id = ?", sshKeyID).
Where("content = ?", sshKeyContent).
Update("last_used_at", time.Now().Unix()).Error
}