Code optimization

This commit is contained in:
刘河
2019-03-29 10:41:57 +08:00
parent 4b0aebd6a5
commit cc6d053b6d
32 changed files with 357 additions and 289 deletions

View File

@@ -23,13 +23,25 @@ func (self *LoginController) Verify() {
server.Bridge.Register.Store(common.GetIpByAddr(self.Ctx.Request.RemoteAddr), time.Now().Add(time.Hour*time.Duration(2)))
}
b, err := beego.AppConfig.Bool("allow_user_login")
if err == nil && b && self.GetString("username") == "user" && !auth {
if err == nil && b && !auth {
file.GetCsvDb().Clients.Range(func(key, value interface{}) bool {
v := value.(*file.Client)
if v.VerifyKey == self.GetString("password") && v.Status {
if !v.Status || v.NoDisplay {
return true
}
if v.WebUserName == "" && v.WebPassword == "" {
if self.GetString("username") != "user" || v.VerifyKey != self.GetString("password") {
return true
} else {
auth = true
}
}
if !auth && v.WebPassword == self.GetString("password") && self.GetString("username") == v.WebUserName {
auth = true
}
if auth {
self.SetSession("isAdmin", false)
self.SetSession("clientId", v.Id)
auth = true
return false
}
return true