mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-08 17:08:04 +02:00
Tweaked project structure (#88)
This commit is contained in:
@ -3,8 +3,8 @@ package ssh
|
||||
import (
|
||||
"errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/git"
|
||||
"github.com/thomiceli/opengist/internal/models"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"gorm.io/gorm"
|
||||
"io"
|
||||
@ -32,12 +32,12 @@ func runGitCommand(ch ssh.Channel, gitCmd string, key string, ip string) error {
|
||||
userName := strings.ToLower(repoFields[0])
|
||||
gistName := strings.TrimSuffix(strings.ToLower(repoFields[1]), ".git")
|
||||
|
||||
gist, err := models.GetGist(userName, gistName)
|
||||
gist, err := db.GetGist(userName, gistName)
|
||||
if err != nil {
|
||||
return errors.New("gist not found")
|
||||
}
|
||||
|
||||
requireLogin, err := models.GetSetting(models.SettingRequireLogin)
|
||||
requireLogin, err := db.GetSetting(db.SettingRequireLogin)
|
||||
if err != nil {
|
||||
return errors.New("internal server error")
|
||||
}
|
||||
@ -52,7 +52,7 @@ func runGitCommand(ch ssh.Channel, gitCmd string, key string, ip string) error {
|
||||
gist.ID == 0 ||
|
||||
requireLogin == "1" {
|
||||
|
||||
pubKey, err := models.SSHKeyExistsForUser(key, gist.UserID)
|
||||
pubKey, err := db.SSHKeyExistsForUser(key, gist.UserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
log.Warn().Msg("Invalid SSH authentication attempt from " + ip)
|
||||
@ -61,7 +61,7 @@ func runGitCommand(ch ssh.Channel, gitCmd string, key string, ip string) error {
|
||||
errorSsh("Failed to get user by SSH key id", err)
|
||||
return errors.New("internal server error")
|
||||
}
|
||||
_ = models.SSHKeyLastUsedNow(pubKey.Content)
|
||||
_ = db.SSHKeyLastUsedNow(pubKey.Content)
|
||||
}
|
||||
|
||||
repositoryPath := git.RepositoryPath(gist.User.Username, gist.Uuid)
|
||||
|
Reference in New Issue
Block a user