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
|
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
|
var model models.PublicKey
|
||||||
|
|
||||||
result := s.db.Model(&models.PublicKey{}).Preload("User").Where(&models.PublicKey{Key: pubkey}).First(&model)
|
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
|
user := model.User
|
||||||
|
|
||||||
token, err := s.doLogin(&user, "", true)
|
token, err := s.doLogin(&user, ip, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
@ -680,7 +680,7 @@ func (s *S5API) accountLogin(jc jape.Context) {
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyAuthenticationFailed, err))
|
s.sendErrorResponse(jc, NewS5Error(ErrKeyAuthenticationFailed, err))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue