mirror of https://github.com/allinssl/allinssl
Merge remote-tracking branch 'origin/1.0.1' into 1.0.1
commit
3bfce79e11
|
@ -133,7 +133,7 @@ func Sign(c *gin.Context) {
|
|||
session.Set("__loginErrCount", 0)
|
||||
session.Delete("__loginErrEnd")
|
||||
session.Set("login", true)
|
||||
session.Set("__login_key", public.GetSettingIgnoreError("login_key"))
|
||||
session.Set("__login_key", public.LoginKey)
|
||||
_ = session.Save()
|
||||
// c.JSON(http.StatusOK, public.ResOK(0, nil, "登录成功"))
|
||||
// 设置cookie
|
||||
|
|
|
@ -131,7 +131,7 @@ func Save(setting *Setting) error {
|
|||
return nil
|
||||
} else {
|
||||
if reload {
|
||||
s.Where("key = 'login_key'", []interface{}{}).Update(map[string]interface{}{"value": public.GenerateUUID()})
|
||||
public.LoginKey = public.GenerateUUID()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -97,13 +97,13 @@ func SessionAuthMiddleware() gin.HandlerFunc {
|
|||
c.Abort()
|
||||
return
|
||||
} else {
|
||||
if session.Get("__login_key") != public.GetSettingIgnoreError("login_key") {
|
||||
if session.Get("__login_key") != public.LoginKey {
|
||||
// session.Set("secure", true)
|
||||
session.Set("login", nil)
|
||||
session.Save()
|
||||
// c.JSON(http.StatusUnauthorized, gin.H{"message": "登录信息发生变化,请重新登录"})
|
||||
c.Redirect(http.StatusFound, "/login")
|
||||
// c.Abort()
|
||||
c.Abort()
|
||||
} else {
|
||||
// 访问正常,更新最后请求时间
|
||||
session.Set("lastRequestTime", now)
|
||||
|
|
|
@ -178,7 +178,7 @@ func init() {
|
|||
);
|
||||
|
||||
`)
|
||||
insertDefaultData(db, "users", "INSERT INTO users (id, username, password, salt) VALUES (1, 'xxxx', 'xxxxxxx', '&*ghs^&%dag');")
|
||||
insertDefaultData(db, "users", "INSERT INTO users (id, username, password, salt) VALUES (1, 'admin', 'xxxxxxx', '&*ghs^&%dag');")
|
||||
insertDefaultData(db, "access_type", `
|
||||
INSERT INTO access_type (name, type) VALUES ('aliyun', 'dns');
|
||||
INSERT INTO access_type (name, type) VALUES ('tencentcloud', 'dns');
|
||||
|
@ -201,10 +201,9 @@ func init() {
|
|||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'workflow_log_path', 'logs/workflows/', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'timeout', '3600', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'https', '0', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ( 'login_key', '%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('session_key', '%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('secure', '/%s', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('port', '%d', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);`, uuidStr, uuidStr, randomStr, port)
|
||||
INSERT INTO settings (key, value, create_time, update_time, active, type) VALUES ('port', '%d', '2025-04-15 15:58', '2025-04-15 15:58', 1, null);`, uuidStr, randomStr, port)
|
||||
|
||||
insertDefaultData(db, "settings", Isql)
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ var Port = GetSettingIgnoreError("port")
|
|||
var Secure = GetSettingIgnoreError("secure")
|
||||
var SessionKey = GetSettingIgnoreError("session_key")
|
||||
var LogPath = GetSettingIgnoreError("log_path")
|
||||
var LoginKey = GenerateUUID()
|
||||
var TimeOut = func() int {
|
||||
settingStr := GetSettingIgnoreError("timeout")
|
||||
setting, err := strconv.Atoi(settingStr)
|
||||
if err != nil {
|
||||
return 300
|
||||
return 3600
|
||||
}
|
||||
return setting
|
||||
}()
|
||||
|
@ -25,7 +26,7 @@ func ReloadConfig() {
|
|||
settingStr := GetSettingIgnoreError("timeout")
|
||||
setting, err := strconv.Atoi(settingStr)
|
||||
if err != nil {
|
||||
TimeOut = 300
|
||||
TimeOut = 3600
|
||||
} else {
|
||||
TimeOut = setting
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ func main() {
|
|||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
public.UpdateSetting("login_key", public.GenerateUUID())
|
||||
envVars["web"] = "restart"
|
||||
err = control()
|
||||
fmt.Println("用户名设置成功:", input)
|
||||
case "6":
|
||||
var input string
|
||||
|
@ -164,8 +165,8 @@ func main() {
|
|||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
public.UpdateSetting("login_key", public.GenerateUUID())
|
||||
|
||||
envVars["web"] = "restart"
|
||||
err = control()
|
||||
fmt.Println("密码设置成功:", input)
|
||||
case "7":
|
||||
var input string
|
||||
|
|
Loading…
Reference in New Issue