public async Task <bool> ConfirmMobile(string code)
        {
            _MobileInfo mobileInfo = await _account.GetCacheMobileActivation();

            if (mobileInfo.Code == code)
            {
                await _account.UpdateMobileAsync(mobileInfo.Number);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public async Task SetCacheMobileActivation(string mobile)
        {
            var appUser = await Current();

            appUser.PhoneNumberDeclared = mobile;
            await _userManager.UpdateAsync(appUser);

            var _mobileInfo = new _MobileInfo {
                Number = mobile, Code = (new Random()).Next(1000, 9999).ToString()
            };

            await _serverCache.SetStringAsync($"{appUser.Email}/mobile", _mobileInfo.ToJson(), new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = new TimeSpan(24, 0, 0, 0)
            });

            await _smsRepository.SendSms(mobile, $"Código {_mobileInfo.Code}. Utiliza este número para confirmar tu celular. De las Artes.");
        }