refactor: set login ip with LoginPubkey

This commit is contained in:
Derrick Hammer 2024-02-26 08:28:22 -05:00
parent 2573936000
commit 355033634d
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 3 additions and 3 deletions

View File

@ -282,7 +282,7 @@ func (s AccountServiceDefault) ValidLoginByUserID(id uint, password string) (boo
return true, &user, nil
}
func (s AccountServiceDefault) LoginPubkey(pubkey string) (string, error) {
func (s AccountServiceDefault) LoginPubkey(pubkey string, ip string) (string, error) {
var model models.PublicKey
result := s.db.Model(&models.PublicKey{}).Preload("User").Where(&models.PublicKey{Key: pubkey}).First(&model)
@ -297,7 +297,7 @@ func (s AccountServiceDefault) LoginPubkey(pubkey string) (string, error) {
user := model.User
token, err := s.doLogin(&user, "", true)
token, err := s.doLogin(&user, ip, true)
if err != nil {
return "", err

View File

@ -680,7 +680,7 @@ func (s *S5API) accountLogin(jc jape.Context) {
return
}
jwt, err := s.accounts.LoginPubkey(hex.EncodeToString(decodedKey[1:])) // Adjust based on how LoginPubkey is implemented
jwt, err := s.accounts.LoginPubkey(hex.EncodeToString(decodedKey[1:]), jc.Request.RemoteAddr)
if err != nil {
s.sendErrorResponse(jc, NewS5Error(ErrKeyAuthenticationFailed, err))
return