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
+6 -7
View File
@@ -81,15 +81,14 @@ func GetUserById(userId uint) (*User, error) {
return user, err
}
func GetUserBySSHKeyID(sshKeyId uint) (*User, error) {
user := new(User)
func SSHKeyExistsForUser(sshKey string, userId uint) (*SSHKey, error) {
key := new(SSHKey)
err := db.
Preload("SSHKeys").
Joins("join ssh_keys on users.id = ssh_keys.user_id").
Where("ssh_keys.id = ?", sshKeyId).
First(&user).Error
Where("content = ?", sshKey).
Where("user_id = ?", userId).
First(&key).Error
return user, err
return key, err
}
func GetUserByProvider(id string, provider string) (*User, error) {