Exemple #1
0
        public async Task <bool> VerifyAsync(TokenVerifyViewModel model, string deviceToken, OsType osType, Language language, string deviceId)
        {
            Verified verified;

            if (Regex.Replace(model.VerificationTerm, @"\s+", "").All(c => Char.IsDigit(c)))
            {
                verified = await _repository.Filter <Verified>(v => v.PhoneCode == model.PhoneCode &&
                                                               v.Phone == model.VerificationTerm && v.VerifiedBy == VerifiedBy.Phone).FirstOrDefaultAsync();
            }
            else
            {
                verified = await _repository.Filter <Verified>(v =>
                                                               v.Email == model.VerificationTerm && v.VerifiedBy == VerifiedBy.Email).FirstOrDefaultAsync();
            }
            if (verified == null || verified.Code != model.Code)
            {
                throw new Exception(_optionsBinder.Error().VerificationCode);
            }
            verified.IsVerified   = true;
            verified.VerifiedType = VerifiedType.Verify;
            _repository.Update(verified);
            await _repository.SaveChangesAsync();

            return(true);
        }
 public async Task <IActionResult> Verify([FromBody] TokenVerifyViewModel model)
 {
     return(await MakeActionCallAsync(async() => await _tokenService.VerifyAsync(model,
                                                                                 GetDeviceToken(), GetOsType(), GetLanguage(), GetDeviceId())));
 }