From 355033634d798fe0e5a1070d6bf48580dd9288fd Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 26 Feb 2024 08:28:22 -0500 Subject: [PATCH] refactor: set login ip with LoginPubkey --- account/account.go | 4 ++-- api/s5/s5.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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