public JsonResult Register(UserInfo info, string VerificationCode) { ServiceResultModel <UserInfo> response = new ServiceResultModel <UserInfo>(); try { if (string.IsNullOrEmpty(info.LoginID)) { response.SetFailed(ResultCodes.ParameterError, "手机号码不能为空");//您输入的LoginID参数不正确 } else if (info.LoginID.Length != 11) { response.SetFailed(ResultCodes.ParameterError, "请正确输入11位数手机号码");//您输入的MobilePhone参数不正确 } else if (string.IsNullOrEmpty(info.LoginPwd)) { response.SetFailed(ResultCodes.ParameterError, "密码不能为空");//您输入的LoginPwd参数不正确 } else if (string.IsNullOrEmpty(info.Name)) { response.SetFailed(ResultCodes.ParameterError, "用户名不能为空");//您输入的Name参数不正确 } else { UserInfo userInfo = this.userManager.GetUserByLoginID(info.LoginID); VerificationCodeInfo verificationCodeInfo = this.userDao.GetLastVerificationCode(info.LoginID); if (userInfo != null) { response.SetFailed(ResultCodes.ParameterError, "您输入的手机号已注册");//您输入的手机号已注册 } else if (verificationCodeInfo == null) { response.SetFailed(ResultCodes.ParameterError, "请点击获取验证码");//请点击获取验证码 } else if (SQLUtil.TrimNull(VerificationCode) != verificationCodeInfo.VerificationCode) { response.SetFailed(ResultCodes.ParameterError, "验证码错误,请重新输入");//验证码错误,请重新输入 } else if ((DateTime.Now - verificationCodeInfo.CreatedTime).TotalMinutes > WebConfig.SMS_PERIOD) { response.SetFailed(ResultCodes.ParameterError, "验证码已失效,请重新获取"); //验证码已失效,请重新获取 } else { info = userManager.RegisterUser(info, verificationCodeInfo.ID); response.Data = info; } } } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message); response.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage); } return(MyJson(response, JsonRequestBehavior.AllowGet)); }
//------------------------------------------------------- // 保存 删除 //------------------------------------------------------- #region 函数:Save(XmlDocument doc) /// <summary>保存信息</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string Save(XmlDocument doc) { VerificationCodeInfo param = new VerificationCodeInfo(); param = AjaxUtil.Deserialize <VerificationCodeInfo>(param, doc); this.service.Save(param); return(MessageObject.Stringify("0", I18n.Strings["msg_save_success"])); }
/// <summary> /// 判断手机号 VCODE 是否有效 /// </summary> /// <param name="telephone"></param> /// <param name="vcode"></param> /// <returns></returns> public VerificationCodeInfo CheckVerificationCode(string telephone, string vcode) { VerificationCodeInfo result = new VerificationCodeInfo(); DataCommand command = new DataCommand(ConnectionString, GetDbCommand(BaseDataStatement.CheckVerificationCodeSql, "Text")); command.AddInputParameter("@Mobile", DbType.String, telephone); command.AddInputParameter("@VCode", DbType.String, vcode); result = command.ExecuteEntity <VerificationCodeInfo>(); return(result); }
/// <remarks/> public void NotifyTelephonePinResetAsync(VerificationCodeInfo info, object userState) { if ((this.NotifyTelephonePinResetOperationCompleted == null)) { this.NotifyTelephonePinResetOperationCompleted = new System.Threading.SendOrPostCallback(this.OnNotifyTelephonePinResetOperationCompleted); } this.InvokeAsync("NotifyTelephonePinReset", new object[] { info }, this.NotifyTelephonePinResetOperationCompleted, userState); }
/// <summary></summary> /// <param name="accountId"></param> /// <param name="phoneNumber"></param> /// <param name="validationType"></param> /// <returns></returns> public int Send(string accountId, string phoneNumber, string validationType) { if (string.IsNullOrEmpty(phoneNumber)) { throw new NullReferenceException(phoneNumber); } string objectType = VerificationObjectType.Mobile.ToString(); // 获取验证码信息 VerificationCodeInfo verificationCode = VerificationCodeContext.Instance.VerificationCodeService.Create(objectType, phoneNumber, validationType, IPQueryContext.GetClientIP()); // 获取验证模板信息 VerificationCodeTemplateInfo template = VerificationCodeContext.Instance.VerificationCodeTemplateService.FindOne(objectType, validationType); string messageContent = TemplateContentContext.Instance.TemplateContentService.GetHtml(template.TemplateContentName); string serialNumber = DateTime.Now.ToString("yyyyMMddHHmmssfff") + StringHelper.ToRandom("0123456789", 3); // 设置短信内容 ShortMessage message = new ShortMessage(); message.SerialNumber = serialNumber; message.PhoneNumber = phoneNumber; message.MessageContent = string.Format(messageContent, verificationCode.Code); if (string.IsNullOrEmpty(template.Options)) { template.Options = "{}"; } // 在参数中加入验证码对象 template.Options = template.Options.Insert(1, "\"code\":\"" + verificationCode.Code + "\","); // 设置短信模板代码 JsonData data = JsonMapper.ToObject(template.Options); message.MessageTemplateCode = JsonHelper.GetDataValue(data, "templateCode"); // message.MessageTemplateParam = "{\"code\":\"" + verificationCode.Code + "\",\"product\":\"" + JsonHelper.GetDataValue(data, "product") + "\"}"; message.MessageTemplateParam = data.ToJson(); // 发送短信 string returnCode = client.Send(message); // 保存结果至数据库 this.provider.Send(serialNumber, accountId, phoneNumber, message.MessageContent, returnCode); if (string.IsNullOrEmpty(returnCode)) { return(0); } return(Convert.ToInt32(returnCode)); }
public async Task <bool> IsVerificationCodeValidAsync(string id, long?userId, short verificationCode) { VerificationCodeInfo vCodeInfo = await GetUserVerificationCodeAsync(id, userId).ConfigureAwait(false); if (vCodeInfo != null && vCodeInfo.VCode == verificationCode) { await cacheRepository.Remove(string.Format(VERIFICATIONCODE_KEY_FORMAT, userId?.ToString() ?? id)).ConfigureAwait(false); return(true); } return(false); }
public static void AddVerificationCode(VerificationCodeEntity entity) { BaseDataRepository mr = new BaseDataRepository(); VerificationCodeInfo info = new VerificationCodeInfo(); info.Mobile = entity.Mobile; info.Email = entity.Email; info.VCode = entity.VCode; info.Status = entity.Status; info.DeadLine = entity.DeadLine; mr.AddVerificationCode(info); }
/// <summary> /// 短信验证码信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public int AddVerificationCode(VerificationCodeInfo info) { DataCommand command = new DataCommand(ConnectionString, GetDbCommand(BaseDataStatement.InsertVerificationCodeSql, "Text")); command.AddInputParameter("@ID", DbType.Int32, info.ID); command.AddInputParameter("@Mobile", DbType.String, info.Mobile); command.AddInputParameter("@Email", DbType.String, info.Email); command.AddInputParameter("@VCode", DbType.String, info.VCode); command.AddInputParameter("@Status", DbType.Int32, info.Status); command.AddInputParameter("@DeadLine", DbType.DateTime, info.DeadLine); command.AddInputParameter("@CreateDate", DbType.DateTime, DateTime.Now); return(command.ExecuteNonQuery()); }
//------------------------------------------------------- // 保存 添加 修改 删除 //------------------------------------------------------- #region 函数:Save(VerificationCodeInfo param) /// <summary>保存记录</summary> /// <param name="param">VerificationCodeInfo 实例详细信息</param> /// <returns>VerificationCodeInfo 实例详细信息</returns> public VerificationCodeInfo Save(VerificationCodeInfo param) { if (!IsExist(param.Id)) { Insert(param); } else { Update(param); } return(param); }
//------------------------------------------------------- // 查询 //------------------------------------------------------- #region 函数:FindOne(XmlDocument doc) /// <summary>获取详细信息</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string FindOne(XmlDocument doc) { StringBuilder outString = new StringBuilder(); string id = XmlHelper.Fetch("id", doc); VerificationCodeInfo param = null; // this.service.FindOne(id); outString.Append("{\"data\":" + AjaxUtil.Parse <VerificationCodeInfo>(param) + ","); outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_query_success"], true) + "}"); return(outString.ToString()); }
internal void NotifyTelephonePinReset(Guid customerId, Guid accountId, string verificationCode) { VerificationCodeInfo info = new VerificationCodeInfo { AccountId = accountId, VerificationCode = verificationCode }; lock (this._ToBeSendEntitiesLock) { this._ToBeSendEntities.Enqueue(info); } this._HasToBeSendEntityEvent.Set(); }
/// <summary>忘记密码</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string ForgotPassword(XmlDocument doc) { string mobile = XmlHelper.Fetch("mobile", doc); string email = XmlHelper.Fetch("email", doc); IAccountInfo account = null; if (!string.IsNullOrEmpty(mobile)) { account = MembershipManagement.Instance.AccountService.FindOneByCertifiedMobile(mobile); if (account != null) { VerificationCodeInfo verificationCode = VerificationCodeContext.Instance.VerificationCodeService.Create("Mobile", mobile, "忘记密码"); EmailClientContext.Instance.Send(mobile, "密码找回", string.Format("尊敬的用户,\r\n您好,您正在通过忘记密码功能找回密码。当前验证码:{0}, \r\nIP:{1}\r\nDate:{2} ", verificationCode.Code, IPQueryContext.GetClientIP(), DateTime.Now.ToString())); return("{message:{\"returnCode\":0,\"value\":\"验证码发送成功。\"}}"); } else { return("{message:{\"returnCode\":1,\"value\":\"验证码发送失败,不存在的手机号码。\"}}"); } } else if (!string.IsNullOrEmpty(email)) { account = MembershipManagement.Instance.AccountService.FindOneByCertifiedEmail(email); if (account != null) { VerificationCodeInfo verificationCode = VerificationCodeContext.Instance.VerificationCodeService.Create("Mail", email, "忘记密码"); IPQueryContext.GetClientIP(); // 您好 {date} 您通过了忘记密码功能找回密码。验证码: {code} // // IP 地址 EmailClientContext.Instance.Send(email, "密码找回", string.Format("尊敬的用户,\r\n您好,您正在通过忘记密码功能找回密码。当前验证码:{0}, \r\nIP:{1}\r\nDate:{2} ", verificationCode.Code, IPQueryContext.GetClientIP(), DateTime.Now.ToString())); return("{message:{\"returnCode\":0,\"value\":\"验证码发送成功。\"}}"); } else { return("{message:{\"returnCode\":1,\"value\":\"验证码发送失败,不存在的邮箱地址。\"}}"); } } return("{message:{\"returnCode\":2,\"value\":\"必须填写手机号码或邮箱地址。\"}}"); }
/// <summary>创建新的验证码</summary> /// <param name="objectType">对象类型</param> /// <param name="objectValue">对象的值</param> /// <param name="validationType">验证方式</param> /// <param name="ip">IP 地址</param> /// <param name="length">验证码长度</param> /// <returns>验证码对象</returns> public VerificationCodeInfo Create(string objectType, string objectValue, string validationType, string ip, int length) { VerificationCodeInfo param = new VerificationCodeInfo(); // datetime(17) + randomtext(6) = 唯一标识长度(23) param.Id = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmssfff"), StringHelper.ToRandom("0123456789", 6)); param.IP = ip; param.ObjectType = objectType; param.ObjectValue = objectValue; param.Code = StringHelper.ToRandom("0123456789", length); param.ValidationType = validationType; param.CreatedDate = DateTime.Now; return(this.provider.Save(param)); }
public async Task <bool> CanRequestSmsCodeAsync(long currentTime, string id, long?userId = null) { VerificationCodeInfo vCodeInfo = await GetUserVerificationCodeAsync(id, userId).ConfigureAwait(false); if (vCodeInfo == null) { return(true); } if (currentTime > vCodeInfo.GenerationTimeSeconds + vCodeInfo.WaitingSeconds) { return(true); } return(false); }
/// <summary> /// 获取验证码 /// </summary> /// <param name="mobilePhone">手机号</param> /// <returns>验证码</returns> public JsonResult GetVerificationCode(string mobilePhone) { ServiceResultModelBase response = new ServiceResultModelBase(); try { if (string.IsNullOrEmpty(mobilePhone)) { response.SetFailed(ResultCodes.ParameterError, "手机号码不能为空");//您输入的MobilePhone参数不正确 } else if (mobilePhone.Length != 11) { response.SetFailed(ResultCodes.ParameterError, "请正确输入11位数手机号码");//您输入的MobilePhone参数不正确 } else { UserInfo userInfo = userManager.GetUserByLoginID(mobilePhone); VerificationCodeInfo verificationCodeInfo = userDao.GetLastVerificationCode(mobilePhone); if (userInfo != null) { response.SetFailed(ResultCodes.ParameterError, "您输入的手机号已注册");//您输入的手机号已注册 } else if (verificationCodeInfo != null && (DateTime.Now - verificationCodeInfo.CreatedTime).TotalMinutes <= WebConfig.SMS_PERIOD) { response.SetFailed(ResultCodes.ParameterError, "短信验证码已发送,请耐心等待");//短信验证码已发送,请耐心等待 } else { if (this.userManager.SendPhoneVerify(mobilePhone, WebConfig.SMS_SDK_APP_ID, WebConfig.SMS_SDK_APP_KEY, WebConfig.SMS_PERIOD, WebConfig.SMS_SIGNATURE, WebConfig.SMS_TEMPLATEID) == false) { response.SetFailed(ResultCodes.ParameterError, "发送短信验证码失败,请重试");//发送短信验证码失败,请重试 } else { response.SetFailed(ResultCodes.Succeed, "短信验证码已发送,请耐心等待");//短信验证码已发送,请耐心等待 } } } } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message); response.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage); } return(MyJson(response, JsonRequestBehavior.AllowGet)); }
public static VerificationCodeEntity CheckVerificationCode(string telephone, string vcode) { BaseDataRepository mr = new BaseDataRepository(); VerificationCodeInfo info = mr.CheckVerificationCode(telephone, vcode); VerificationCodeEntity entity = new VerificationCodeEntity(); if (info != null) { entity.Mobile = info.Mobile; entity.Email = info.Email; entity.VCode = info.VCode; entity.Status = info.Status; entity.DeadLine = info.DeadLine; } return(entity); }
/// <summary>创建新的对象</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string CreateNewObject(XmlDocument doc) { StringBuilder outString = new StringBuilder(); VerificationCodeInfo param = new VerificationCodeInfo(); param.Id = StringHelper.ToGuid(); param.CreatedDate = DateTime.Now; outString.Append("{\"data\":" + AjaxUtil.Parse <VerificationCodeInfo>(param) + ","); outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_create_success"], true) + "}"); return(outString.ToString()); }
public async Task <Response> CreateResponseAsync() { UserVm resultUser; VerificationCodeInfo verificationCode = await verificationCodesService .GetUserVerificationCodeAsync(request.Value, clientConnection.UserId).ConfigureAwait(false); if (isPhoneEditing) { if (await loadUsersService.IsPhoneExistsAsync(request.Value).ConfigureAwait(false)) { var errorObject = new { Phone = $"Phone number {request.Value} already exists" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ObjectsLibrary.Enums.ErrorCode.WrongArgumentError)); } if (verificationCode != null && verificationCode.VCode == request.VCode && request.Value == verificationCode.Id) { resultUser = await updateUsersService.UpdateUserPhoneAsync(clientConnection.UserId.Value, request.Value).ConfigureAwait(false); } else { return(new ResultResponse(request.RequestId, "Wrong verification code.", ObjectsLibrary.Enums.ErrorCode.WrongVerificationCode)); } } else { if (await loadUsersService.IsEmailExistsAsync(request.Value).ConfigureAwait(false)) { var errorObject = new { Email = $"Email {request.Value} already exists" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ObjectsLibrary.Enums.ErrorCode.WrongArgumentError)); } if (verificationCode != null && verificationCode.VCode == request.VCode && request.Value == verificationCode.Id) { resultUser = await updateUsersService.UpdateUserEmailAsync(clientConnection.UserId.Value, request.Value).ConfigureAwait(false); } else { return(new ResultResponse(request.RequestId, "Wrong verification code.", ObjectsLibrary.Enums.ErrorCode.WrongVerificationCode)); } } return(new UsersResponse(request.RequestId, resultUser)); }
/// <summary></summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string SendVerificationMail(XmlDocument doc) { if (SecurityConfigurationView.Instance.CaptchaMode == "ON") { // 验证码 string captcha = XmlHelper.Fetch("captcha", doc); if (HttpContext.Current.Session["captcha"] == null || captcha != HttpContext.Current.Session["captcha"].ToString()) { return("{\"message\":{\"returnCode\":1,\"value\":\"验证码错误。\"}}"); } } // 检查验证码发送时间 if (HttpContext.Current.Session["VerificationCodeSendTime"] != null && HttpContext.Current.Session["VerificationCodeSendTime"] is DateTime) { DateTime time = (DateTime)HttpContext.Current.Session["VerificationCodeSendTime"]; if (time.AddSeconds(VerificationCodeConfigurationView.Instance.SendInterval) > DateTime.Now) { return("{\"message\":{\"returnCode\":1,\"value\":\"发送太频繁,请稍后再试。\"}}"); } } // 邮件地址 string email = XmlHelper.Fetch("email", doc); // 验证类型 string validationType = XmlHelper.Fetch("validationType", doc); VerificationCodeInfo verificationCode = VerificationCodeContext.Instance.VerificationCodeService.Create("Mail", email, validationType, IPQueryContext.GetClientIP()); VerificationCodeTemplateInfo template = VerificationCodeContext.Instance.VerificationCodeTemplateService.FindOne("Mail", validationType); JsonData options = JsonMapper.ToObject(template.Options); string content = TemplateContentContext.Instance.TemplateContentService.GetHtml(template.TemplateContentName); EmailClientContext.Instance.Send(email, JsonHelper.GetDataValue(options, "subject"), string.Format(content, verificationCode.Code), EmailFormat.Html); HttpContext.Current.Session["VerificationCodeSendTime"] = DateTime.Now; return("{\"message\":{\"returnCode\":0,\"value\":\"发送成功。\"}}"); }
/// <summary>校验验证码</summary> /// <param name="objectType">对象类型</param> /// <param name="objectValue">对象的值</param> /// <param name="validationType">验证方式</param> /// <param name="code">验证码</param> /// <param name="availableMinutes">有效分钟数</param> /// <returns>布尔值</returns> public bool Validate(string objectType, string objectValue, string validationType, string code, int availableMinutes) { VerificationCodeInfo param = this.FindOne(objectType, objectValue, validationType); // 判断对象是否存在 if (param == null) { return(false); } else { // 校验时间有效性 if (availableMinutes > 0 && param.CreatedDate.AddMinutes(availableMinutes) < DateTime.Now) { return(false); } // 校验验证码 return(param.Code == code); } }
public async Task <short> CreateVerificationCodeAsync(long currentTime, string id, long?userId = null) { VerificationCodeInfo existingCode = await GetUserVerificationCodeAsync(userId?.ToString() ?? id).ConfigureAwait(false); VerificationCodeInfo vCodeInfo; if (existingCode == null) { short verificationCode; verificationCode = (short)RandomExtensions.NextInt32(1000, 9999); vCodeInfo = new VerificationCodeInfo(verificationCode, currentTime, id, 30, userId); } else { short extendedTime = (existingCode.WaitingSeconds * 2) < short.MaxValue ? (short)(existingCode.WaitingSeconds * 2) : existingCode.WaitingSeconds; vCodeInfo = new VerificationCodeInfo(existingCode.VCode, currentTime, id, extendedTime, userId); } await cacheRepository.AddObject(string.Format(VERIFICATIONCODE_KEY_FORMAT, userId?.ToString() ?? id), vCodeInfo).ConfigureAwait(false); return(vCodeInfo.VCode); }
//------------------------------------------------------- // 保存 删除 //------------------------------------------------------- #region 函数:Save(VerificationCodeInfo param) /// <summary>保存记录</summary> /// <param name="param"> 实例<see cref="VerificationCodeInfo"/>详细信息</param> /// <returns>VerificationCodeInfo 实例详细信息</returns> public VerificationCodeInfo Save(VerificationCodeInfo param) { return(this.provider.Save(param)); }
public async Task <Response> CreateResponseAsync() { if (!NodeSettings.Configs.Node.UserRegistrationAllowed) { return(new ResultResponse(request.RequestId, "User registration is not allowed.", ErrorCode.PermissionDenied)); } UserVm user = request.User; try { VerificationCodeInfo verificationCode = null; if (!request.User.Phones.IsNullOrEmpty() && request.User.Emails.IsNullOrEmpty()) { if (NodeSettings.Configs.Node.RegistrationMethod == RegistrationMethod.EmailRequired) { var errorObject = new { Email = "Email required" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } if (await loadUsersService.IsPhoneExistsAsync(request.User.Phones.FirstOrDefault().FullNumber).ConfigureAwait(false)) { var errorObject = new { Phone = "Phone already exists" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } verificationCode = await verificationCodesService.GetUserVerificationCodeAsync(request.User.Phones.FirstOrDefault().FullNumber).ConfigureAwait(false); } else if (request.User.Phones.IsNullOrEmpty() && !request.User.Emails.IsNullOrEmpty()) { if (NodeSettings.Configs.Node.RegistrationMethod == RegistrationMethod.PhoneRequired) { var errorObject = new { Email = "Phone required" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } if (await loadUsersService.IsEmailExistsAsync(request.User.Emails.FirstOrDefault()).ConfigureAwait(false)) { var errorObject = new { Email = "Email already exists." }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } verificationCode = await verificationCodesService.GetUserVerificationCodeAsync(request.User.Emails.FirstOrDefault()).ConfigureAwait(false); } else { if (NodeSettings.Configs.Node.RegistrationMethod != RegistrationMethod.NothingRequired) { var errorObject = new { Email = "Email only or phone only", Phone = "Email only or phone only" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } } if (verificationCode != null && verificationCode.VCode != request.VCode && (!request.User.Emails.IsNullOrEmpty() || !request.User.Phones.IsNullOrEmpty())) { var errorObject = new { VCode = "Wrong verification code" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongVerificationCode)); } ValuePair <UserVm, string> userPasswordPair = await createUsersService.CreateNewUserAsync(user, NodeSettings.Configs.Node.Id, NodeSettings.Configs.ConfirmUsers).ConfigureAwait(false); TokenVm tempTokens = await tokensService.CreateTokenPairByUserIdAsync(userPasswordPair.FirstValue.Id.GetValueOrDefault(), false, 30 * 60).ConfigureAwait(false); clientConn.FileAccessToken = RandomExtensions.NextString(64); BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateNewUserSegmentAsync( userPasswordPair.FirstValue, NodeSettings.Configs.Node.Id, NodeData.Instance.NodeKeys.SignPrivateKey, NodeData.Instance.NodeKeys.SymmetricKey, NodeData.Instance.NodeKeys.Password, NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false); BlockGenerationHelper.Instance.AddSegment(segment); ShortUser shortUser = new ShortUser { UserId = userPasswordPair.FirstValue.Id.GetValueOrDefault(), PrivateData = segment.PrivateData }; nodeNoticeService.SendNewUsersNodeNoticeAsync(shortUser, segment); return(new TokensResponse( request.RequestId, userPasswordPair.FirstValue, tempTokens.AccessToken, tempTokens.RefreshToken, clientConn.FileAccessToken, userPasswordPair.SecondValue)); } catch (CreateNewUserException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, ex.Message, ErrorCode.UnknownError)); } }
/// <summary>���Ӽ�¼</summary> /// <param name="param">ʵ��<see cref="VerificationCodeInfo"/>��ϸ��Ϣ</param> public void Insert(VerificationCodeInfo param) { this.ibatisMapper.Insert(StringHelper.ToProcedurePrefix(string.Format("{0}_Insert", tableName)), param); }
/// <summary>修改记录</summary> /// <param name="param">VerificationCodeInfo 实例的详细信息</param> public void Update(VerificationCodeInfo param) { this.ibatisMapper.Update(StringHelper.ToProcedurePrefix(string.Format("{0}_Update", tableName)), param); }
private void Send(object emailEntity) { try { Execution execution = emailEntity as Execution; if (execution != null) { Logger.InfoFormat("TransactonServer.NotifyExecution(before send) OrderId= {0}", execution.OrderId); this._EmailService.NotifyOrderExecuted(execution.OrderId); Logger.InfoFormat("TransactonServer.NotifyExecution(after send) OrderId= {0}", execution.OrderId); return; } AccountRisk accountRisk = emailEntity as AccountRisk; if (accountRisk != null) { this._EmailService.NotifyRiskLevelChanged(accountRisk.ToRiskLevelChangedInfo()); return; } BalanceInfo balanceInfo = emailEntity as BalanceInfo; if (balanceInfo != null) { this._EmailService.NotifyBalanceChanged(balanceInfo); return; } OrderDeleted orderDeleted = emailEntity as OrderDeleted; if (orderDeleted != null) { this._EmailService.NotifyOrderDeleted(orderDeleted.OrderId); return; } TradeDayReset tradeDayReset = emailEntity as TradeDayReset; if (tradeDayReset != null) { this._EmailService.NotifyResetStatement(tradeDayReset.TradeDay.Day); this.SetTradeDayResetEmailGenerated(tradeDayReset.TradeDay.Day); return; } PasswordResetInfo passwordResetInfo = emailEntity as PasswordResetInfo; if (passwordResetInfo != null) { this._EmailService.NotifyPasswordReset(passwordResetInfo); } VerificationCodeInfo verificationCodeInfo = emailEntity as VerificationCodeInfo; if (verificationCodeInfo != null) { this._EmailService.NotifyTelephonePinReset(verificationCodeInfo); } ApplyDelivery applyDelivery = emailEntity as ApplyDelivery; if (applyDelivery != null) { this._EmailService.NotifyDeliveryListing(applyDelivery.DeliveryRequestId); } } catch (Exception exception) { Logger.Error(emailEntity.ToString(), exception); } }
/// <summary>忘记密码</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string SetPassword(XmlDocument doc) { // Registration 注册类型: email | mobile | default string registration = XmlHelper.Fetch("registration", doc); // 手机号码 string mobile = XmlHelper.Fetch("mobile", doc); // 邮箱地址 string email = XmlHelper.Fetch("email", doc); // 验证码 string code = XmlHelper.Fetch("code", doc); // 密码 string password = XmlHelper.Fetch("password", doc); VerificationCodeInfo verificationCode = null; IAccountInfo account = null; if (registration == "mail") { verificationCode = VerificationCodeContext.Instance.VerificationCodeService.FindOne(VerificationObjectType.Mail.ToString(), email, "忘记密码"); } else if (registration == "mobile") { verificationCode = VerificationCodeContext.Instance.VerificationCodeService.FindOne(VerificationObjectType.Mobile.ToString(), mobile, "忘记密码"); } if (verificationCode.Code != code) { return("{message:{\"returnCode\":2,\"value\":\"验证码错误。\"}}"); } if (registration == "mail") { account = MembershipManagement.Instance.AccountService.FindOneByCertifiedEmail(email); } else if (registration == "mobile") { account = MembershipManagement.Instance.AccountService.FindOneByCertifiedMobile(mobile); } if (account != null) { // 生成一个包含大写字母、小写字母、数字、特殊字符的八位长度的字符串 /* * string password = Guid.NewGuid().ToString().Substring(0, 5); * * Random random = new Random(); * * password = password.Insert(random.Next(password.Length), StringHelper.ToRandom("!@#$", 1)); * * password = password.Insert(random.Next(password.Length), StringHelper.ToRandom("abcdefghijkmnpqrstuvwxyz", 1)); * * password = password.Insert(random.Next(password.Length), StringHelper.ToRandom("ABCDEFGHJKLMNPQRSTUVWXYZ", 1)); * * MembershipManagement.Instance.AccountService.SetPassword(account.Id, Encrypter.EncryptSHA1(password)); */ // 通过了{date}忘记密码功能找回密码 // IP 地址 // EmailClientContext.Instance.Send(email, "密码找回", "新的密码:" + password); MembershipManagement.Instance.AccountService.SetPassword(account.Id, password); return("{message:{\"returnCode\":0,\"value\":\"密码设置成功。\"}}"); } else { return("{message:{\"returnCode\":1,\"value\":\"不存在的用户信息。\"}}"); } }
public void NotifyTelephonePinReset(VerificationCodeInfo info) { this.Invoke("NotifyTelephonePinReset", new object[] { info }); }
/// <remarks/> public void NotifyTelephonePinResetAsync(VerificationCodeInfo info) { this.NotifyTelephonePinResetAsync(info, null); }