diff --git a/account/account.go b/account/account.go index ec9d87c..4e91787 100644 --- a/account/account.go +++ b/account/account.go @@ -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 diff --git a/api/s5/s5.go b/api/s5/s5.go index 3224acf..d5fbb0a 100644 --- a/api/s5/s5.go +++ b/api/s5/s5.go @@ -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