refactor: set login ip with LoginPubkey
This commit is contained in:
parent
2573936000
commit
355033634d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue