mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 17:38:04 +02:00
Fix perms for http/ssh clone (#288)
This commit is contained in:
@ -48,13 +48,12 @@ func GetSSHKeyByID(sshKeyId uint) (*SSHKey, error) {
|
||||
return sshKey, err
|
||||
}
|
||||
|
||||
func SSHKeyDoesExists(sshKeyContent string) (*SSHKey, error) {
|
||||
sshKey := new(SSHKey)
|
||||
err := db.
|
||||
Where("content like ?", sshKeyContent+"%").
|
||||
First(&sshKey).Error
|
||||
|
||||
return sshKey, err
|
||||
func SSHKeyDoesExists(sshKeyContent string) (bool, error) {
|
||||
var count int64
|
||||
err := db.Model(&SSHKey{}).
|
||||
Where("content = ?", sshKeyContent).
|
||||
Count(&count).Error
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
func (sshKey *SSHKey) Create() error {
|
||||
|
@ -118,6 +118,15 @@ func GetUsersFromEmails(emailsSet map[string]struct{}) (map[string]*User, error)
|
||||
return userMap, nil
|
||||
}
|
||||
|
||||
func GetUserFromSSHKey(sshKey string) (*User, error) {
|
||||
user := new(User)
|
||||
err := db.
|
||||
Joins("JOIN ssh_keys ON users.id = ssh_keys.user_id").
|
||||
Where("ssh_keys.content = ?", sshKey).
|
||||
First(&user).Error
|
||||
return user, err
|
||||
}
|
||||
|
||||
func SSHKeyExistsForUser(sshKey string, userId uint) (*SSHKey, error) {
|
||||
key := new(SSHKey)
|
||||
err := db.
|
||||
|
Reference in New Issue
Block a user