德州扑克游戏平台下载 当前位置:首页>德州扑克游戏平台下载>正文

德州扑克游戏平台下载

发布时间:2018-11-22

原标题:8、ABPZero系列教程之拼多多卖家工具 添加手机注册登录功能

高仙芝的眉头皱成一团,如果没有包抄围堵的话,连云堡外围的吐蕃军就可以从南边逃走了。

橙光游戏

大礼完成,唐三将小舞先放在地上,然后珍而重之的把大明和二明的尸体收入到自己的如意百宝囊之中,强忍着不让自己再流下泪水。大明和二明最后的期盼他还没有完成,唐三认为,现在的自己还没有哭的资格。
那人转身,面色威严,肤色略黑,正是燕王朱棣,当日平蓝玉一案立下大功,蓝玉一死,大明军中可大用之人寥寥无几,朱元璋多疑,始终相信自己人,李景隆毕竟年轻,一来带兵经验不足,二来难以服众,那些多年摸爬滚打的军中将领未必会服一个乳臭未干的娃娃,朱棣不同,早年率兵征战,有军功在身,加上又是王爷身份,办起事来同样容易。

他话音刚落,那马匪头子却一刀插入他的心脏,夏宦官惨叫而死,马匪首领夺过圣旨,打开看了看,他点点头,将圣旨揣进怀中,一摆手道:“我们走!”

  现在网站基本都用手机注册,很少用邮箱注册,本篇内容比较多,代码我会尽量加备注,有些操作需要连续添加几个文件才不报错,如果VS显示错误,请继续后续步骤。

前面已经有一篇文章讲到集成短信发送模块:http://www.cnblogs.com/shensigzs/category/1147235.html

在此基础上才能做手机注册功能,没有完成的同学请先去整合后再回来。

语言文件

AbpZeroTemplate-zh-CN.xml文件末尾添加如下键值对:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.CoreLocalizationAbpZeroTemplateAbpZeroTemplate-zh-CN.xml

<text name="MobileRegister" value="手机注册" />
<text name="OccupiedMobilePhone" value="手机号码已注册或被占用" />
<text name="MobilePhone" value="手机号码" />

 

 

添加模型文件

在Web项目下ModelsAccount目录下添加MobileRegisterViewModel.cs,代码如下:

文件路径:D:abpwebPddSellerAssistantPddSellerAssistant.WebModelsAccountMobileRegisterViewModel.cs

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Abp.Auditing;
using MyCompanyName.AbpZeroTemplate.Authorization.Users;
using MyCompanyName.AbpZeroTemplate.Security;
using MyCompanyName.AbpZeroTemplate.Validation;
using MyCompanyName.AbpZeroTemplate.MultiTenancy;

namespace MyCompanyName.AbpZeroTemplate.Web.Models.Account
{
    public class MobileRegisterViewModel : IValidatableObject
    {
        [StringLength(Tenant.MaxTenancyNameLength)]
        public string TenancyName { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        [Required]
        [StringLength(User.MaxMobilePhoneLength)]
        public string MobilePhone { get; set; }

        /// <summary>
        /// 手机验证码
        /// </summary>
        [Required]
        [StringLength(User.MobileCodeLength)]
        public string MobilePhoneCode { get; set; }

        [StringLength(User.MaxPlainPasswordLength)]
        [DisableAuditing]
        public string Password { get; set; }
        public PasswordComplexitySetting PasswordComplexitySetting { get; set; }
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!string.IsNullOrWhiteSpace(MobilePhone))
            {
                if (new ValidationHelper().IsPhoneNumber(MobilePhone) == false)
                {
                    yield return new ValidationResult("您输入的手机号码无效 !");
                }
            }
            else
            {
                yield return new ValidationResult("手机号码不能为空 !");
            }
        }
    }
}

 

Core项目

User.cs类添加如下代码:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.CoreAuthorizationUsersUser.cs

public const int MaxMobilePhoneLength = 11;
public const int MobileCodeLength = 6;

 

再打开ValidationHelper.cs,添加如下代码:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.CoreValidationValidationHelper.cs

/// <summary>
        /// 验证手机号是否有效
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        public bool IsPhoneNumber(string phoneNumber)
        {
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                return false;
            }
            string pattern = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$";
            return Regex.IsMatch(phoneNumber, pattern);

        }

 

 UserStore.cs类添加如下代码:

文件路径:D:abpwebPddSellerAssistantPddSellerAssistant.CoreAuthorizationUsersUserStore.cs

private readonly IRepository<User, long> _userRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;

 

 _userRepository = userRepository;
_unitOfWorkManager = unitOfWorkManager;
#region 扩展方法
        /// <summary>
        /// 按手机号码查询用户
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        public virtual async Task<User> FindByPhoneNumberAsync(string phoneNumber)
        {

            return await _userRepository.FirstOrDefaultAsync(
                user => user.PhoneNumber == phoneNumber
                );
        }

        [UnitOfWork]
        public virtual async Task<User> FindByPhoneNumberAsync(int? tenantId, string phoneNumber)
        {
            using (_unitOfWorkManager.Current.SetTenantId(tenantId))
            {
                return await FindByPhoneNumberAsync(phoneNumber);
            }
        }
        #endregion

 

AbpZeroTemplateConsts.cs添加如下代码:

文件路径:D:abpwebPddSellerAssistantPddSellerAssistant.CoreAbpZeroTemplateConsts.cs

#region 手机短信模板
        /// <summary>
        /// 手机短信验证码通用模板
        /// </summary>
        public const string SmsTemplateCommonCode = "SMS_119088461";
        #endregion

 

UserManager.cs 重写CreateAsync、CheckDuplicateUsernameOrEmailAddressAsync方法,代码如下:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.CoreAuthorizationUsersUserManager.cs

public override async Task<IdentityResult> CreateAsync(User user)
        {
            var result = await CheckDuplicateUsernameOrEmailAddressAsync(user.Id, user.UserName, user.EmailAddress);
            if (!result.Succeeded)
            {
                return result;
            }
            if (string.IsNullOrWhiteSpace(user.EmailAddress))
            {
                user.EmailAddress = string.Empty;
            }


            var tenantId = GetCurrentTenantId();
            if (tenantId.HasValue && !user.TenantId.HasValue)
            {
                user.TenantId = tenantId.Value;
            }

            try
            {
                return await base.CreateAsync(user);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

        }

        public override async Task<IdentityResult> CheckDuplicateUsernameOrEmailAddressAsync(long? expectedUserId, string userName, string emailAddress)
        {
            var user = (await FindByNameAsync(userName));
            if (user != null && user.Id != expectedUserId)
            {
                return AbpIdentityResult.Failed(string.Format(L("Identity.DuplicateName"), userName));
            }


            return IdentityResult.Success;
        }

        private int? GetCurrentTenantId()
        {
            if (_unitOfWorkManager.Current != null)
            {
                return _unitOfWorkManager.Current.GetTenantId();
            }

            return AbpSession.TenantId;
        }

        private string L(string name)
        {
            return LocalizationManager.GetString(AbpZeroConsts.LocalizationSourceName, name);
        }

 

Application项目 

MyAbpLoginResultType.cs添加这个类,代码如下:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.ApplicationAuthorizationMyAbpLoginResultType.cs

namespace MyCompanyName.AbpZeroTemplate.Authorization
{
    public enum MyAbpLoginResultType : byte
    {
        /// <summary>
        /// 手机号码未验证
        /// </summary>
        UserMobilePhoneNotConfirmed = 10
    }
}

 

 

LogInManager.cs扩展这个类,代码如下:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.ApplicationAuthorizationLogInManager.cs

private readonly IMultiTenancyConfig _multiTenancyConfig;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IRepository<Tenant> _tenantRepository;
private readonly AbpUserManager<Role, User> _userManager;
private readonly UserStore _userStore;

 

public LogInManager(
            UserManager userManager, 
            IMultiTenancyConfig multiTenancyConfig, 
            IRepository<Tenant> tenantRepository, 
            IUnitOfWorkManager unitOfWorkManager, 
            ISettingManager settingManager, 
            IRepository<UserLoginAttempt, long> userLoginAttemptRepository, 
            IUserManagementConfig userManagementConfig, 
            IIocResolver iocResolver, 
            RoleManager roleManager,
            UserStore userStore)
            : base(
                  userManager, 
                  multiTenancyConfig, 
                  tenantRepository, 
                  unitOfWorkManager, 
                  settingManager, 
                  userLoginAttemptRepository, 
                  userManagementConfig, 
                  iocResolver, 
                  roleManager)
        {
            _multiTenancyConfig = multiTenancyConfig;
            _unitOfWorkManager = unitOfWorkManager;
            _tenantRepository = tenantRepository;
            _userManager = userManager;
            _userStore = userStore;
        }

 

public virtual async Task<AbpLoginResult<Tenant, User>> LoginByMobileAsync(string mobilePhone, string plainPassword, string tenancyName = null,
            bool shouldLockout = true)
        {
            var result = await LoginByMobileAsyncInternal(mobilePhone, plainPassword, tenancyName, shouldLockout);
            await SaveLoginAttempt(result, tenancyName, mobilePhone);
            return result;
        }

        protected async Task<AbpLoginResult<Tenant, User>> LoginByMobileAsyncInternal(string mobilePhone, string plainPassword, string tenancyName, bool shouldLockout)
        {
            if (mobilePhone.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(mobilePhone));
            }

            if (plainPassword.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(plainPassword));
            }

            //Get and check tenant
            Tenant tenant = null;
            using (_unitOfWorkManager.Current.SetTenantId(null))
            {
                if (!_multiTenancyConfig.IsEnabled)
                {
                    tenant = await GetDefaultTenantAsync();
                }
                else if (!string.IsNullOrWhiteSpace(tenancyName))
                {
                    tenant = await _tenantRepository.FirstOrDefaultAsync(t => t.TenancyName == tenancyName);
                    if (tenant == null)
                    {
                        return new AbpLoginResult<Tenant, User>(AbpLoginResultType.InvalidTenancyName);
                    }

                    if (!tenant.IsActive)
                    {
                        return new AbpLoginResult<Tenant, User>(AbpLoginResultType.TenantIsNotActive, tenant);
                    }
                }
            }

            var tenantId = tenant == null ? (int?)null : tenant.Id;
            using (_unitOfWorkManager.Current.SetTenantId(tenantId))
            {
                var user = await _userStore.FindByPhoneNumberAsync(tenantId, mobilePhone);
                if (user == null)
                {
                    return new AbpLoginResult<Tenant, User>(AbpLoginResultType.InvalidUserNameOrEmailAddress, tenant);
                }

                _userManager.InitializeLockoutSettings(tenantId);

                if (await _userManager.IsLockedOutAsync(user.Id))
                {
                    return new AbpLoginResult<Tenant, User>(AbpLoginResultType.LockedOut, tenant, user);
                }

                var verificationResult = _userManager.PasswordHasher.VerifyHashedPassword(user.Password, plainPassword);
                if (verificationResult != PasswordVerificationResult.Success)
                {
                    if (shouldLockout)
                    {
                        if (await TryLockOutAsync(tenantId, user.Id))
                        {
                            return new AbpLoginResult<Tenant, User>(AbpLoginResultType.LockedOut, tenant, user);
                        }
                    }

                    return new AbpLoginResult<Tenant, User>(AbpLoginResultType.InvalidPassword, tenant, user);
                }

                await _userManager.ResetAccessFailedCountAsync(user.Id);

                return await CreateLoginByMobileResultAsync(user, tenant);
            }
        }

        protected async Task<AbpLoginResult<Tenant, User>> CreateLoginByMobileResultAsync(User user, Tenant tenant = null)
        {
            if (!user.IsActive)
            {
                return new AbpLoginResult<Tenant, User>(AbpLoginResultType.UserIsNotActive);
            }

            if (!user.IsPhoneNumberConfirmed)
            {
                return new AbpLoginResult<Tenant, User>((AbpLoginResultType)MyAbpLoginResultType.UserMobilePhoneNotConfirmed);
            }

            user.LastLoginTime = Clock.Now;

            await _userManager.AbpStore.UpdateAsync(user);

            await _unitOfWorkManager.Current.SaveChangesAsync();

            return new AbpLoginResult<Tenant, User>(
                tenant,
                user,
                await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)
            );
        }

 

 

Web项目

CodeHelper.cs添加此类,代码如下:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.WebHelpersCodeHelper.cs

/// <summary>
        /// 生成6位手机验证码
        /// </summary>
        /// <returns></returns>
        public static string SetNewPhoneCode()
        {
            var c = RandomHelper.GetRandom(100000, 999999);
            return c + "";
        }

 

AccountController.cs添加如下代码,大概351行位置:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.WebControllersAccountController.cs

/// <summary>
        /// 手机注册
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult RegisterByMobile()
        {
            return MobileRegisterView(new MobileRegisterViewModel
            {
                TenancyName = _tenancyNameFinder.GetCurrentTenancyNameOrNull(),
                PasswordComplexitySetting = JsonConvert.DeserializeObject<PasswordComplexitySetting>(SettingManager.GetSettingValue(AppSettings.Security.PasswordComplexity))
            });

        }

        public ActionResult MobileRegisterView(MobileRegisterViewModel model)
        {
            CheckSelfRegistrationIsEnabled();

            ViewBag.IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled;

            return View("RegisterByMobile", model);
        }

 

 [HttpPost]
        [UnitOfWork]
        public virtual async Task<ActionResult> RegisterByMobile(MobileRegisterViewModel model)
        {
            try
            {

                CheckSelfRegistrationIsEnabled();
                VaildateMobile(model.MobilePhoneCode);
                //判断手机号是否被占用
                var ur = await _userManager.Users.Where(
                u => u.PhoneNumber == model.MobilePhone
                ).FirstOrDefaultAsync();
                if (ur != null)
                {
                    throw new UserFriendlyException(L("OccupiedMobilePhone"));
                }

                if (!_multiTenancyConfig.IsEnabled)
                {
                    model.TenancyName = Tenant.DefaultTenantName;
                }
                else if (model.TenancyName.IsNullOrEmpty())
                {
                    throw new UserFriendlyException(L("TenantNameCanNotBeEmpty"));
                }

                CurrentUnitOfWork.SetTenantId(null);

                var tenant = await GetActiveTenantAsync(model.TenancyName);

                CurrentUnitOfWork.SetTenantId(tenant.Id);

                if (!await SettingManager.GetSettingValueForTenantAsync<bool>(AppSettings.UserManagement.AllowSelfRegistration, tenant.Id))
                {
                    throw new UserFriendlyException(L("SelfUserRegistrationIsDisabledMessage_Detail"));
                }

                await _userPolicy.CheckMaxUserCountAsync(tenant.Id);

                //Getting tenant-specific settings
                var isNewRegisteredUserActiveByDefault = await SettingManager.GetSettingValueForTenantAsync<bool>(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault, tenant.Id);
                var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueForTenantAsync<bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin, tenant.Id);

                var user = new User
                {
                    TenantId = tenant.Id,
                    IsActive = isNewRegisteredUserActiveByDefault,
                    PhoneNumber = model.MobilePhone,
                    IsPhoneNumberConfirmed = true
                };

                ExternalLoginInfo externalLoginInfo = null;
                //用户名或密码为空,抛出异常
                if (model.MobilePhone.IsNullOrEmpty() || model.Password.IsNullOrEmpty())
                {
                    throw new UserFriendlyException(L("FormIsNotValidMessage"));
                }

                user.UserName = model.MobilePhone;
                user.Password = new PasswordHasher().HashPassword(model.Password);

                user.Roles = new List<UserRole>();
                foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
                {
                    user.Roles.Add(new UserRole(tenant.Id, user.Id, defaultRole.Id));
                }
                
                CheckErrors(await _userManager.CreateAsync(user));
                await _unitOfWorkManager.Current.SaveChangesAsync();


                //通知
                await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());
                await _appNotifier.WelcomeToTheApplicationAsync(user);
                await _appNotifier.NewUserRegisteredAsync(user);

                //如果可能,直接登录
                if (user.IsActive && user.IsPhoneNumberConfirmed)
                {
                    AbpLoginResult<Tenant, User> loginResult;
                    loginResult = await GetLoginByMobileResultAsync(user.UserName, model.Password, tenant.TenancyName);

                    if (loginResult.Result == AbpLoginResultType.Success)
                    {
                        await SignInAsync(loginResult.User, loginResult.Identity);
                        
                        return Redirect(Url.Action("Index", "Application"));
                    }

                    Logger.Warn("新注册的用户无法登录。 这不应该是正常。 登录结果: " + loginResult.Result);
                }

                return View("RegisterResult", new RegisterResultViewModel
                {
                    TenancyName = tenant.TenancyName,
                    NameAndSurname = user.Name + " " + user.Surname,
                    UserName = user.UserName,
                    EmailAddress = user.EmailAddress,
                    IsActive = user.IsActive,
                    IsEmailConfirmationRequired = isEmailConfirmationRequiredForLogin
                });
            }
            catch (UserFriendlyException ex)
            {
                ViewBag.IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled;
                ViewBag.UseCaptcha = UseCaptchaOnRegistration();
                ViewBag.ErrorMessage = ex.Message;
                ViewBag.ErrorDetails = ex.Details;

                return View("RegisterByMobile", model);
            }
        }

 

 

/// <summary>
        /// 手机验证码验证
        /// </summary>
        /// <param name="mobilePhoneCode"></param>
        private void VaildateMobile(string mobilePhoneCode)
        {
            if (mobilePhoneCode.Length != Authorization.Users.User.MobileCodeLength)
            {
                throw new UserFriendlyException(string.Format("验证码必须为 {0} 位!", Authorization.Users.User.MobileCodeLength));
            }
            //手机验证码效验
            var phoneCode = Session["PhoneCode"];
            var now = Session["PhoneCodeDateTime"];
            if (phoneCode == null || string.IsNullOrWhiteSpace(phoneCode.ToString()))
            {
                throw new UserFriendlyException("您输入的验证码无效!");
            }
            var nowTime = Convert.ToDateTime(now);
            var t = DateTime.Now - nowTime;
            if (t.TotalSeconds >= 180)
            {
                throw new UserFriendlyException("您输入的验证码无效!");
            }
            if (!mobilePhoneCode.Equals(phoneCode.ToString()))
            {
                throw new UserFriendlyException("您输入的验证码不正确!");
            }
        }

        private async Task<AbpLoginResult<Tenant, User>> GetLoginByMobileResultAsync(string mobilePhone, string password, string tenancyName)
        {
            var loginResult = await _logInManager.LoginByMobileAsync(mobilePhone, password, tenancyName);

            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    return loginResult;
                default:
                    throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(loginResult.Result, mobilePhone, tenancyName);
            }
        }

 

VerificationCodeController.cs添加此控制器,代码如下:

文件路径:D:abp versionaspnet-zero-3.4.0aspnet-zero-3.4.0srcMyCompanyName.AbpZeroTemplate.WebControllersVerificationCodeController.cs

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Abp.Net.Sms;
using Abp.UI;
using MyCompanyName.AbpZeroTemplate.Authorization.Users;
using MyCompanyName.AbpZeroTemplate.MultiTenancy;
using MyCompanyName.AbpZeroTemplate.Validation;
using MyCompanyName.AbpZeroTemplate.Web.Helpers;

namespace MyCompanyName.AbpZeroTemplate.Web.Controllers
{
    public class VerificationCodeController : AbpZeroTemplateControllerBase
    {
        private readonly UserManager _userManager;
        private readonly ISmsSender _smsSender;
        private readonly TenantManager _tenantManager;
        private readonly IUserEmailer _userEmailer;

        public VerificationCodeController(UserManager userManager,
            ISmsSender smsSender,
            TenantManager tenantManager,
            IUserEmailer userEmailer)
        {
            _userManager = userManager;
            _smsSender = smsSender;
            _tenantManager = tenantManager;
            _userEmailer = userEmailer;
        }
        #region 手机

        /// <summary>
        /// 注册时使用,发送手机验证码
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<JsonResult> SendMobileCode(string phoneNumber)
        {
            try
            {
                if (!new ValidationHelper().IsPhoneNumber(phoneNumber))
                {
                    throw new UserFriendlyException("您输入了无效的手机号码!");
                }
                //检查手机是否已被注册
                var user = await _userManager.Users.Where(
                u => u.PhoneNumber == phoneNumber
                ).FirstOrDefaultAsync();

                if (user != null)
                {
                    throw new UserFriendlyException(L("OccupiedMobilePhone"));
                }
                //生成6位数字验证码
                var code = CodeHelper.SetNewPhoneCode();
                //发送验证码
                await _smsSender.SendAsync(phoneNumber, AbpZeroTemplateConsts.SmsTemplateCommonCode, "{"code":"" + code + ""}");
                //存储验证码、手机号、时间,以备验证使用
                Session["PhoneCode"] = code;
                Session["PhoneNumber"] = phoneNumber;
                Session["PhoneCodeDateTime"] = DateTime.Now;
                return Json("OK", JsonRequestBehavior.DenyGet);
            }
            catch (Exception ex)
            {
                throw new UserFriendlyException(ex.Message);
            }
        }


        
        /// <summary>
        ///验证手机时使用,发送手机验证码
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<JsonResult> SendMobileCodeByVerificationMobile(string phoneNumber)
        {
            try
            {
                if (!new ValidationHelper().IsPhoneNumber(phoneNumber))
                {
                    throw new UserFriendlyException("您输入了无效的手机号码!");
                }
                //检查手机是否已被注册
                var user = await _userManager.Users.Where(
                u => u.PhoneNumber == phoneNumber && u.Id != AbpSession.UserId
                ).FirstOrDefaultAsync();

                if (user != null)
                {
                    throw new UserFriendlyException(L("OccupiedMobilePhone"));
                }
                //生成6位数字验证码
                var code = CodeHelper.SetNewPhoneCode();
                //发送验证码
                await _smsSender.SendAsync(phoneNumber, AbpZeroTemplateConsts.SmsTemplateCommonCode, "{"code":"" + code + ""}");
                //存储验证码、手机号、时间,以备验证使用
                Session["PhoneCode"] = code;
                Session["PhoneNumber"] = phoneNumber;
                Session["PhoneCodeDateTime"] = DateTime.Now;
                return Json("OK", JsonRequestBehavior.DenyGet);
            }
            catch (Exception ex)
            {
                throw new UserFriendlyException(ex.Message);
            }
        }

        #endregion

        #region private
        /// <summary>
        /// 检查手机号码是否已被注册,未注册抛出异常
        /// </summary>
        /// <param name="mobilePhone"></param>
        /// <returns></returns>
        private async Task<User> GetUserByCheckingMobile(string mobilePhone)
        {
            var user = await _userManager.Users.Where(
                u => u.PhoneNumber == mobilePhone
                ).FirstOrDefaultAsync();

            if (user == null)
            {
                throw new UserFriendlyException(L("InvalidMobilePhone"));
            }

            return user;
        }
        
        #endregion
    }
}

 

添加视图

添加RegisterByMobile.cshtml视图文件,代码如下:

文件路径:D:abpwebPddSellerAssistantPddSellerAssistant.WebViewsAccountRegisterByMobile.cshtml

@model MyCompanyName.AbpZeroTemplate.Web.Models.Account.MobileRegisterViewModel
@using System.Web.Script.Serialization
@using Abp.Extensions
@using Abp.Web.Mvc.Extensions
@using MyCompanyName.AbpZeroTemplate.MultiTenancy
@using Recaptcha.Web
@using Recaptcha.Web.Mvc
@section 

编辑:伯徒北

发布时间:2018-11-22 00:00:00

当前文章:http://radiokey.biz/content/2018-11/10/content_33898.html

电玩捕鱼24小时兑换 方块娱乐全民官网 集结号棋牌下载 杰克棋牌官网官方网站 金星棋牌2018官方下载 现金扑克官网 新出的可提现棋牌游戏 鱼扑克手机版

92040 13946 58391 64082 21728 6717613164 46915 11574

责任编辑:侯戏海华

随机推荐