修改密码

This commit is contained in:
hahwu 2025-05-27 10:44:21 +08:00
parent 0786f52259
commit 075ba32e99
3 changed files with 1890 additions and 1732 deletions

View File

@ -243,6 +243,11 @@ func GetAccountInfoFromDb(name string) *Db_Account {
return &res
}
func UpdateAccountInfoToDb(account *Db_Account) (err error) {
_, err = SqlDb.Exec("UPDATE t_account SET user_password = ? WHERE user_name = ?", account.UserPassword, account.UserName)
return
}
func FormatAllMemLoadDb(u interface{}, tableName string, Exclude string) (err error) {
t := reflect.TypeOf(u)
len := t.Elem().NumField()

View File

@ -61,6 +61,45 @@ func HandleClientReq(args []interface{}) {
// log.Debug("消息Func : %s", m.GetFunc())
switch m.GetFunc() {
case "ClientTick":
case "ReqChangePassword":
detail := &msg.ReqChangePassword{}
proto.Unmarshal(buf, detail)
accountInfo := db.GetAccountInfoFromDb(detail.UserName)
if accountInfo == nil {
ResChangePassword := &msg.ResChangePassword{}
ResChangePassword.ResultCode = MergeConst.Protocol_Error_Account_NoExsit
data, _ := proto.Marshal(ResChangePassword)
G_GameLogicPtr.PackResInfo(a, "ResChangePassword", data)
return
}
if accountInfo.UserPassword != detail.OldPwd && detail.OldPwd != "-1" {
ResChangePassword := &msg.ResChangePassword{}
ResChangePassword.ResultCode = MergeConst.Protocol_Error_Account_OR_PWD_ERROR
data, _ := proto.Marshal(ResChangePassword)
G_GameLogicPtr.PackResInfo(a, "ResChangePassword", data)
return
}
if strings.Count(detail.NewPwd, "")-1 < 6 {
ResChangePassword := &msg.ResChangePassword{}
ResChangePassword.ResultCode = MergeConst.Protocol_Error_Account_OR_PWD_Short
data, _ := proto.Marshal(ResChangePassword)
G_GameLogicPtr.PackResInfo(a, "ResChangePassword", data)
return
}
accountInfo.UserPassword = detail.NewPwd
err := db.UpdateAccountInfoToDb(accountInfo)
if err != nil {
ResChangePassword := &msg.ResChangePassword{}
ResChangePassword.ResultCode = MergeConst.Protocol_Error_Account_Fail
data, _ := proto.Marshal(ResChangePassword)
G_GameLogicPtr.PackResInfo(a, "ResChangePassword", data)
return
}
ResChangePassword := &msg.ResChangePassword{}
ResChangePassword.ResultCode = 0
data, _ := proto.Marshal(ResChangePassword)
G_GameLogicPtr.PackResInfo(a, "ResChangePassword", data)
case "ReqAdminInfo":
AdminProcess(m.GetFunc(), []interface{}{a, buf})
case "ReqServerVersion":

File diff suppressed because it is too large Load Diff