Skip to content

Commit

Permalink
fix: 安全登录
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Dec 29, 2024
1 parent 5337620 commit 40d6b2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"crypto/rsa"
"crypto/sha256"
"encoding/gob"
"fmt"
"net"
Expand All @@ -12,7 +13,6 @@ import (
"github.com/go-rat/sessions"
"github.com/knadh/koanf/v2"
"github.com/spf13/cast"
"golang.org/x/crypto/sha3"

"github.com/TheTNB/panel/internal/biz"
"github.com/TheTNB/panel/internal/http/request"
Expand Down Expand Up @@ -93,7 +93,10 @@ func (s *UserService) Login(w http.ResponseWriter, r *http.Request) {
}
if req.SafeLogin && !s.conf.Bool("http.tls") {
sess.Put("safe_login", true)
sess.Put("safe_client", fmt.Sprintf("%x", sha3.Sum256([]byte(ip))))
sess.Put("safe_client", fmt.Sprintf("%x", sha256.Sum256([]byte(ip))))
} else {
sess.Forget("safe_login")
sess.Forget("safe_client")
}

sess.Put("user_id", user.ID)
Expand Down

0 comments on commit 40d6b2c

Please sign in to comment.