예제 #1
0
        //private readonly PersonBiz _personBiz;

        public UserBiz(
            ApplicationUserManager userManager,
            ApplicationSignInManager signInManager,
            IAuthenticationManager iAuthenticationManager,
            //AddressBiz addressBiz,
            IRepositry <ApplicationUser> entityDal,
            CountryBiz countryBiz,
            BizParameters bizParameters)
            : base(entityDal, bizParameters)
        {
            _countryBiz = countryBiz;
            //_addressBiz = addressBiz;
            UserManager             = userManager;
            SignInManager           = signInManager;
            _iAuthenticationManager = iAuthenticationManager;

            _store       = new RoleStore <IdentityRole>();
            _roleManager = new RoleManager <IdentityRole>(_store);

            //_personBiz = personBiz;
        }
예제 #2
0
        /// <summary>
        /// This fixes the phone number and then checks against the phone number if he user is found.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> IsPhoneConfirmed(ForgotPasswordViewModel model)
        {
            //var AppUser = await UserManager.FindByNameAsync(model.Phone);
            if (model.Phone.IsNullOrWhiteSpace())
            {
                return(false);
            }

            //if (MessageCollector.IsNull())
            //    MessageCollector = new List<string>();

            //MessageCollector.Add("Entered IsPhoneConfirmed");
            //first fix the phone number
            Country country = CountryBiz.FindAll().FirstOrDefault(x => x.Id == model.CountryId);

            if (country.IsNull())
            {
                return(false);
            }

            string fixedPhoneNumber = PhoneNumberFixer(model.Phone, country.Abbreviation);
            //MessageCollector.Add("fixedPhoneNumber = " + fixedPhoneNumber);

            ApplicationUser appUser = FindAll().FirstOrDefault(x => x.PhoneNumber == fixedPhoneNumber && x.PhoneNumberConfirmed == true);

            //MessageCollector.Add("AppUser.ID = " + appUser.Id);

            if (appUser == null || !(await UserManager.IsEmailConfirmedAsync(appUser.Id)))
            {
                // Don't reveal that the user does not exist or is not confirmed
                return(false);
            }

            AppUser = appUser;
            Code    = await UserManager.GeneratePasswordResetTokenAsync(appUser.Id);

            //MessageCollector.Add("Code = " + Code);

            return(true);
        }