private void OnUpdateEmailVerify(Datagram datagram) { UpdateEmailVerify req = datagram.UnSerialData <UpdateEmailVerify>(); UpdateEmailResponse response = new UpdateEmailResponse(); if (EmailRequestCache.TryRemove(req.NextLabel, out EmailRequestPackage value)) { if (InternalTools.VerificateCode(value.Verify, req.Verifies)) { Guid guid = Guid.NewGuid(); if (SQLDB.UpdateEmail(value.UserID, value.Email)) { response.NextLabel = guid; } } } datagram.DataType = DatagramType.Client; datagram.MessageType = LoginMessageType.UpdateEmailResult; datagram.Datas = response.ToByteArray(); if (!Send(datagram.ToByteArray())) { Notify(IKXTServer.LogLevel.Error, "数据发送异常"); Close(); } }
private void OnUpdateEmailReq(Datagram datagram) { UpdateEmailReq req = datagram.UnSerialData <UpdateEmailReq>(); UpdateEmailResponse response = new UpdateEmailResponse(); if (!SQLDB.CheckEmail(req.UserEmail)) { if (SQLDB.SelectUserInfor(req.UserID, out UserInfoPackage info)) { Guid request_id = Guid.NewGuid(); byte[] ver_code = InternalTools.GenerateVerification(); if (EmailRequestCache.TryAdd(request_id, new EmailRequestPackage { UserID = info.ID, Email = req.UserEmail, Verify = ver_code, Time = DateTime.Now })) { if ( InternalTools.SendUpdateEmailVerificateEmail ( req.UserEmail, InternalTools.GenerateVerification(ver_code) ) ) { response.NextLabel = request_id; } } } } datagram.DataType = DatagramType.Client; datagram.MessageType = LoginMessageType.UpdateEmailRes; datagram.Datas = response.ToByteArray(); if (!Send(datagram.ToByteArray())) { Notify(IKXTServer.LogLevel.Error, "数据发送异常"); Close(); } }