Ejemplo n.º 1
0
        public async Task <CallBackUrl> Register(string email, string password)
        {
            if (!Validate.EmailValidation(email))
            {
                throw new ValidationException("Invalid inputs");
            }

            if (!Validate.PasswordValidation(password))
            {
                throw new ValidationException("Invalid inputs");
            }

            ApplicationUser user = new ApplicationUser {
                UserName = email, Email = email
            };
            IdentityResult result = await _userManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                try
                {
                    _accountsRepository.AddAccount(GuidBuilder.Create().ToString(), user.Id);
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
                    // Send an email with this link
                    string code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    string callbackUrl = Url.Action("ConfirmEmail", "Profile", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
                    await _emailSender.SendEmailAsync(email, "Please confirm your email address",
                                                      $"Please confirm your account by clicking this link: <a href='{callbackUrl}'>link</a> or by entering this code in the app: " + code);

                    return(new CallBackUrl()
                    {
                        Url = callbackUrl
                    });
                }
                catch (Exception ex)
                {
                    await _userManager.DeleteAsync(user);

                    throw new ValidationException("Could not create user:"******"Could not create user");
            }
        }
Ejemplo n.º 2
0
 private string PresentBarcode(string accountToPresent)
 {
     if (tr != null)
     {
         barcodeValue = BuildQRCodeValue(tr.GetAmountAuthorized_9F02(), accountToPresent, GuidBuilder.Create());
         if (!String.IsNullOrEmpty(barcodeValue))
         {
             zxingBIV.BarcodeOptions.Hints.Clear();
             zxingBIV.BarcodeOptions.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
             zxingBIV.BarcodeValue          = barcodeValue;
             zxingBIV.BarcodeOptions.Width  = 600;
             zxingBIV.BarcodeOptions.Height = 600;
         }
     }
     return(barcodeValue);
 }