mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
chore: fixes
This commit is contained in:
@@ -32,7 +32,7 @@ func (s *Server) authModdleware(c *gin.Context) {
|
||||
auth = strings.TrimPrefix(auth, "Bearer ")
|
||||
log.Infof("current token: %v", auth)
|
||||
token, err := jwt.ParseWithClaims(auth, &jwt.RegisteredClaims{}, func(t *jwt.Token) (interface{}, error) {
|
||||
return []byte(secretKey), nil
|
||||
return []byte(s.jwtSerect), nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("parse token error: %v", err)
|
||||
@@ -60,7 +60,6 @@ type LoginIn struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
const secretKey = "r1OF7nhpNjnYiGKtTLuKEVq7YznzT"
|
||||
|
||||
func (s *Server) Login(c *gin.Context) (interface{}, error) {
|
||||
var in LoginIn
|
||||
@@ -89,7 +88,7 @@ func (s *Server) Login(c *gin.Context) (interface{}, error) {
|
||||
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||
NotBefore: jwt.NewNumericDate(time.Now()),
|
||||
})
|
||||
sig, err := token.SignedString([]byte(secretKey))
|
||||
sig, err := token.SignedString([]byte(s.jwtSerect))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "sign")
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ type Server struct {
|
||||
cron *cron.Cron
|
||||
language string
|
||||
tasks map[int]*Task
|
||||
jwtSerect string
|
||||
}
|
||||
|
||||
func (s *Server) Serve() error {
|
||||
s.scheduler()
|
||||
s.reloadTasks()
|
||||
s.jwtSerect = s.db.GetSetting(db.JwtSerectKey)
|
||||
//st, _ := fs.Sub(ui.Web, "build/web")
|
||||
s.r.Use(static.Serve("/", static.EmbedFolder(ui.Web, "build/web")))
|
||||
|
||||
|
||||
@@ -154,5 +154,6 @@ func (s *Server) DeleteFromWatchlist(c *gin.Context) (interface{}, error) {
|
||||
if err := s.db.DeleteSeries(id); err != nil {
|
||||
return nil, errors.Wrap(err, "delete db")
|
||||
}
|
||||
os.RemoveAll(filepath.Join(db.ImgPath, ids)) //delete image related
|
||||
return "success", nil
|
||||
}
|
||||
Reference in New Issue
Block a user