/// <summary> /// 获取 验证码 /// </summary> /// <param name="input">验证码Input</param> public async Task GetValidateCode(ValidateCodeInput input) { if (input.CodeType == CodeType.注册) { if (UserRepo.CheckExists(p => p.UserName == input.CodeKey)) { throw new UserFriendlyException("手机号已注册,不能获取注册验证码."); } } if (input.CodeType == CodeType.找回密码 || input.CodeType == CodeType.动态登录) { if (!UserRepo.CheckExists(p => p.UserName == input.CodeKey)) { throw new UserFriendlyException("该用户未注册,不能获取验证码."); } } if (input.ValidateType == ValidateType.手机) { await SendValidateCode(input, code => { var smsContent = "您本次的验证码为" + code + ",工作人员不会向您索要此验证码,请勿向任何人泄露。[不同]"; //Sms.Send(phoneNo, 1, smsContent); }); } else { await SendValidateCode(input, code => { string subject = "验证码"; string body = "您本次的验证码为" + code + ",工作人员不会向您索要此验证码,请勿向任何人泄露。[不同]"; EmailSender.Send(input.CodeKey, subject, body); }); } }
public async Task ChangeUserName(ChangeUserNameInput input) { await ValidateCode(input.ValidateCode); var user = await UserManager.GetUserByIdAsync(AbpSession.UserId.Value); if (!await UserManager.CheckPasswordAsync(user, input.Password)) { throw new UserFriendlyException("密码错误"); } if (UserRepo.CheckExists(p => p.UserName == input.UserName, AbpSession.UserId.Value)) { throw new UserFriendlyException("该用户名已存在"); } user.UserName = input.UserName; await UserRepo.UpdateAsync(user); }