public async Task <IActionResult> PutEmailVerification(long id, EmailVerification emailVerification)
        {
            if (id != emailVerification.vID)
            {
                return(BadRequest());
            }

            _context.Entry(emailVerification).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmailVerificationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <EmailVerification> > PostEmailVerification(EmailVerification emailVerification)
        {
            _context.EmailVerifications.Add(emailVerification);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmailVerification", new { id = emailVerification.vID }, emailVerification));
        }
Esempio n. 3
0
        public void TestMemberMonashGsbCommunity()
        {
            // Create a member.

            var community = TestCommunity.MonashGsb.CreateTestCommunity(_communitiesCommand, _verticalsCommand, _contentEngine);
            var member    = CreateMember(community);

            _activeCommunity = ActiveCommunity.Monash;

            // Create an email verification.

            var emailVerification = new EmailVerification {
                UserId = member.Id, EmailAddress = member.GetBestEmailAddress().Address
            };

            _emailVerificationsCommand.CreateEmailVerification(emailVerification);

            // Send the email.

            var templateEmail = new ActivationEmail(member, emailVerification);

            _emailsCommand.TrySend(templateEmail);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(Return, Return, member);
            email.AssertSubject(GetSubject());
            email.AssertHtmlViewChecks();
            email.AssertHtmlView(GetBody(templateEmail, member, GetContent(templateEmail, member, emailVerification)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
        public async Task <bool> AddCustomer(VerificationHelperModel customerModel)
        {
            try
            {
                EmailVerification emailVerification = await _context.EmailVerifications.FirstOrDefaultAsync(e => e.Email == customerModel.EmailVerification.Email).ConfigureAwait(false);

                if (emailVerification.VerificationCode != customerModel.EmailVerification.VerificationCode ||
                    emailVerification.ExpirationTime.CompareTo(DateTime.Now) ! < 0)
                {
                    return(false);
                }
                if (_context.Customers.ToList().Any(c => c.Email == customerModel.Customer.Email))
                {
                    return(false);
                }
                Customer customer = _mapper.Map <Customer>(customerModel.Customer);
                customer.Salt       = Hashing.GetSalt();
                customer.CustomerId = Guid.NewGuid();
                customer.Password   = Hashing.GenerateHash(customer.Password, customer.Salt);
                _context.Customers.Add(customer);
                _context.Accounts.Add(new Entities.Account()
                {
                    CustomerId = customer.CustomerId,
                    AccountId  = Guid.NewGuid(),
                    OpenDate   = DateTime.Now
                });
                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        private void Send(IUser user, string emailAddress, Func <IMember, EmailVerification, TemplateEmail> createEmail)
        {
            // Only supported for members at the moment.

            var member = user as IMember;

            if (member == null)
            {
                return;
            }

            // Don't send if there is already one out there.

            var emailVerification = _emailVerificationsQuery.GetEmailVerification(member.Id, emailAddress);

            if (emailVerification != null)
            {
                return;
            }

            // Create a new verification and send an email.

            emailVerification = new EmailVerification {
                EmailAddress = emailAddress, UserId = member.Id
            };
            _emailVerificationsCommand.CreateEmailVerification(emailVerification);

            _emailsCommand.TrySend(createEmail(member, emailVerification));
        }
Esempio n. 6
0
        public void TestMember()
        {
            // Create a member.

            var member = CreateMember();

            // Create an email verification.

            var emailVerification = new EmailVerification {
                UserId = member.Id, EmailAddress = member.GetBestEmailAddress().Address
            };

            _emailVerificationsCommand.CreateEmailVerification(emailVerification);

            // Send the email.

            var templateEmail = new ActivationEmail(member, emailVerification);

            _emailsCommand.TrySend(templateEmail);

            // Check.

            var email = _emailServer.AssertEmailSent();

            email.AssertAddresses(Return, Return, member);
            email.AssertSubject(GetSubject());
            email.AssertViewChecks(MediaTypeNames.Text.Html);
            email.AssertView(MediaTypeNames.Text.Html, GetBody(templateEmail, member, GetContent(templateEmail, member, emailVerification)));
            email.AssertNoAttachments();
            AssertCompatibleAddresses(email);
        }
Esempio n. 7
0
        public void TestRedirect()
        {
            // Create the member.

            var member = _memberAccountsCommand.CreateTestMember(0, false);

            // Create a verification.

            var emailVerification = new EmailVerification {
                UserId = member.Id, EmailAddress = member.GetBestEmailAddress().Address
            };

            _emailVerificationsCommand.CreateEmailVerification(emailVerification);

            // Browse to the page.

            var activationUrl = GetActivationUrl(emailVerification.VerificationCode).AsNonReadOnly();

            var returnUrl = new ReadOnlyApplicationUrl("~/search/jobs");

            activationUrl.QueryString["returnUrl"] = returnUrl.PathAndQuery;
            Get(activationUrl);

            // Check for the redirect.

            AssertUrl(returnUrl);

            // Check the user flags again.

            member = _membersQuery.GetMember(member.Id);
            Assert.IsNotNull(member);
            Assert.IsTrue(member.IsActivated);
        }
Esempio n. 8
0
        private void ActivateButton_Click(object sender, RoutedEventArgs e)
        {
            this.MessageLabel.Visibility = Visibility.Hidden;
            this.MessageBox.Visibility   = Visibility.Hidden;
            if (string.IsNullOrEmpty(this.ActivationCodeField.Text))
            {
                this.MessageLabel.Text = "Activation code may not be empty.";
                this.P2PEditor.GuiLogMessage(this.MessageLabel.Text.ToString(), NotificationLevel.Info);
                this.MessageLabel.Visibility = Visibility.Visible;
                this.ActivationCodeField.Focus();
                return;
            }

            if (!Verification.IsValidPassword(this.PasswordField.Password))
            {
                this.MessageLabel.Text = "Password is not valid.";
                this.P2PEditor.GuiLogMessage(this.MessageLabel.Text.ToString(), NotificationLevel.Info);
                this.MessageLabel.Visibility = Visibility.Visible;
                this.PasswordField.Password  = "";
                this.PasswordField.Focus();
                return;
            }

            Requesting = true;
            Thread thread = new Thread(new ParameterizedThreadStart(ActivateEmail));

            thread.CurrentCulture   = Thread.CurrentThread.CurrentCulture;
            thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            EmailVerification emailVer = new EmailVerification(this.ActivationCodeField.Text, false);

            thread.Start(emailVer);
        }
Esempio n. 9
0
        public ActionResult Registration(CustomerRegistrationEntity customerRegistrationEntity)
        {
            StoreDBEntities1 entities = new StoreDBEntities1();

            try
            {
                entities.spCustomerRegistration(
                    customerRegistrationEntity.Email,
                    customerRegistrationEntity.FName,
                    customerRegistrationEntity.LName,
                    customerRegistrationEntity.Address,
                    customerRegistrationEntity.Password
                    );
                entities.SaveChanges();
                ViewBag.Email = customerRegistrationEntity.Email;
                Random r = new Random();
                Session["OTP"] = r.Next(1111, 9999);
                //change email parameter after testing
                bool emailSent = EmailVerification.SendEmailOTP(Convert.ToInt32(Session["OTP"]), "*****@*****.**", customerRegistrationEntity.FName);
                if (emailSent)
                {
                    return(View("Verification"));
                }
                return(View("Registration"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(View("Registration"));
        }
Esempio n. 10
0
        void IEmailVerificationsCommand.CreateEmailVerification(EmailVerification emailVerification)
        {
            emailVerification.Prepare();
            Validate(emailVerification);

            _repository.CreateEmailVerification(emailVerification);
        }
Esempio n. 11
0
        public ActionResult Index(LoginAreaLogin login)
        {
            StoreDBEntities1 entities = new StoreDBEntities1();
            ObjectParameter  status   = new ObjectParameter("Status", 0);

            ObjectResult <int?> logincode = entities.spCustomerLogin(login.Email, login.Password, status);
            int loginCode = (int)logincode.FirstOrDefault <int?>();

            if (loginCode > 0)
            {
                if (loginCode > 1)
                {
                    Session["CustomerEmail"] = login.Email;
                    return(View("Shopping"));
                }
                ViewBag.CustomerVerification = false;
                ViewBag.Email = login.Email;
                Random r = new Random();
                Session["OTP"] = r.Next(1111, 9999);
                //change email parameter after testing
                bool emailSent = EmailVerification.SendEmailOTP(Convert.ToInt32(Session["OTP"]), "*****@*****.**", login.Email);
                return(View("Verification"));
            }
            ViewBag.CustomerCredentials = false;
            return(View());
        }
Esempio n. 12
0
        public async Task <bool> UpdateVerificationCodeAsync(string email, int verificationCode)
        {
            try
            {
                EmailVerification emailVerification = await _accountContext.EmailVerificationS.FirstOrDefaultAsync(
                    e => e.Email == email);

                if (emailVerification == null)
                {
                    throw new AccountNotFoundException("we didn't find this email");//which exception
                }
                emailVerification.VerificationCode = verificationCode;
                //take the minutes number fron config file
                emailVerification.ExpirationTime = DateTime.Now.AddMinutes(60);
                await _accountContext.SaveChangesAsync();

                //?? how to return(to ask?)
                return(true);
            }
            catch (Exception)
            {
                //todo
                throw new EmailVerificationException("..");
            }
        }
Esempio n. 13
0
        public async Task <bool> CreateAsync(Customer customer)
        {
            var isExsits = _accountRepository.IsEmailExistsAsync(customer.Email);

            if (isExsits.Result == false)
            {
                customer.PasswordSalt = Hashing.GetSalt();
                customer.PasswordHash = Hashing.GenerateHash(customer.Password, customer.PasswordSalt);
                var isCreated = await _accountRepository.CreateAccountAsync(customer);

                if (isCreated == false)
                {
                    throw new Exception("Creation failed");
                }
                EmailVerification emailVerification = new EmailVerification()
                {
                    Email            = customer.Email,
                    VerificationCode = GenerateRandomNo(1000, 9999),
                    ExpirationTime   = DateTime.Now.AddMinutes(60)
                };
                await _verificationRepository.CreateEmailVerificationAsync(emailVerification);

                await _verificationService.SendVerificationCodeAsync(emailVerification);

                return(true);
            }
            return(false);
        }
Esempio n. 14
0
        public void TestActivation()
        {
            // Create the member.

            var member = _memberAccountsCommand.CreateTestMember(0, false);

            // Create a verification.

            var emailVerification = new EmailVerification {
                UserId = member.Id, EmailAddress = member.GetBestEmailAddress().Address
            };

            _emailVerificationsCommand.CreateEmailVerification(emailVerification);

            // Browse to the page.

            var activationUrl = GetActivationUrl(emailVerification.VerificationCode);

            Get(activationUrl);

            // Check that the email address is set on the page.

            AssertUrl(activationUrl);
            Assert.AreEqual(member.GetLoginId(), _loginIdTextBox.Text);
            Assert.IsTrue(_loginButton.IsVisible);

            // Check the user flags again.

            member = _membersQuery.GetMember(member.Id);
            Assert.IsNotNull(member);
            Assert.IsTrue(member.IsActivated);
        }
Esempio n. 15
0
        // Activate user
        public ActionResult Activate(string UserId)
        {
            try
            {
                if (UserId != null)
                {
                    db = new ApplicationDbContext();
                    var user = db.Users.Where(a => a.Id == UserId).FirstOrDefault();
                    user.UserStatus = UserStatus.Active;
                    db.SaveChanges();
                    var body = "<div style='text-align:center;'><h1>مرحباً بك فى بورصة كابيتال</h1>";
                    body += "<h3 style='color:green;'>تم تفعيل حسابك على بورصة كابيتال بنجاح</h3>";
                    body += "<h2>شكراً لاستخدامك بورصة كابيتال</h2>";
                    body += "<h2>من فضلك اضغط <a href='http://sa.borsacapital.com/#/Login'>هنــا لتسجيل الدخول</a> للموقع</h2>";
                    body += "<p>إذا واجهتك اى مشاكل او اذا كنت تريد الاستفسار عن اى شئ من فضلك لا تتردد فى <a href='http://sa.borsacapital.com/#/ContactUs'>التواصل معنا</a></p>";

                    body += "<br /><br />";

                    body += "<div style='text-align:center;'><h1>Welcome to Borsa Capital</h1>";
                    body += "<h3 style='color:green;'>Your account has been activeted succesfuly.</h3>";
                    body += "<h2>Thank you for using Borsa Capital</h2>";
                    body += "<h2>Please click <a href='http://sa.borsacapital.com/#/Login' > here to login</a> the site</h2>";
                    body += "<p>If you facing any problem or any question please don't hesitate to <a href='http://sa.borsacapital.com/#/ContactUs'>contact us</a></p>";
                    string msg = EmailVerification.SendEMail(user.Email, "Borsa Capital Admission", body);
                }

                var users = db.Users.Where(a => a.Roles.Count == 0).ToList();
                return(PartialView("_PartialUsers", users));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Error", "Home", new { area = "" }));
            }
        }
        public async Task SendVerificationCodeAsync(EmailVerification emailVerification)
        {
            int verificationCode;

            if (emailVerification.ExpirationTime <= DateTime.Now)
            {
                verificationCode = _accountService.GenerateRandomNo(1000, 9999);
                bool succeeded = await _verificationRepository.UpdateVerificationCodeAsync(emailVerification.Email, verificationCode);
            }
            else
            {
                verificationCode = emailVerification.VerificationCode;
            }

            string subject = "Verification Code - Brix ";
            //string subject = ConfigurationManager.AppSettings["VerificationEmailSubject"];

            // string body = $"Hello {email} </br>  your verify number is {code} </br><a href='http://*****:*****@"Hello " + email + "</br>  your verify number is " + code + "</br><a href='http://*****:*****@"
                    <head> 
                        <style> 
                            body{background-color:cadetblue;direction:rtl;text-align:center;}
                            h1,h3,p{font-size:20px; text-align:center;color:blue;}
                        </style>
                    </head>
                    <body>";

            htmlText += "<h1> hello " + emailVerification.Email + "  </h1>" +
                        "<p>" + " your verify number is " + verificationCode + " </p>" +
                        " </ br >< a href = 'http://localhost:4200/verification' > our site </ a > " +
                        "</body>";
            await SendEmail(emailVerification.Email, subject, htmlText);
        }
Esempio n. 17
0
 void IRegistrationRepository.CreateEmailVerification(EmailVerification emailVerification)
 {
     using (var dc = CreateContext())
     {
         dc.EmailVerificationEntities.InsertOnSubmit(emailVerification.Map());
         dc.SubmitChanges();
     }
 }
Esempio n. 18
0
 public FriendInvitationEmail(ICommunicationUser to, ICommunicationUser from, FriendInvitation invitation, EmailVerification emailVerification, IList <Job> currentJobs, int contactCount)
     : base(to, from)
 {
     _invitation        = invitation;
     _emailVerification = emailVerification;
     _currentJobs       = currentJobs;
     _contactCount      = contactCount;
 }
Esempio n. 19
0
        //Create new profile
        public void ClickEmailVerificationLink()
        {
            TestUtlity Utlity = new TestUtlity();

            Utlity.Login(driver);
            EmailVerification Email = new EmailVerification();

            Email.ClickVerificationLink(driver, test, extent);
        }
Esempio n. 20
0
 public ReactivationEmail(IMember to, EmailVerification emailVerification)
     : base(GetMember(to, new EmailAddress { Address = emailVerification.EmailAddress, IsVerified = true }))
 {
     if (emailVerification == null)
     {
         throw new ArgumentNullException("emailVerification");
     }
     _emailVerification = emailVerification;
 }
        // return ?
        public async Task ReSendVerificationCodeAsync(string email)
        {
            EmailVerification verificationEmail = await _verificationRepository.GetVerificationDetails(email);

            await SendVerificationCodeAsync(verificationEmail);

            //if resend has to send another code' we have to change the fubction UpdateVerificationCodeAsync
            //or to crate another one
        }
Esempio n. 22
0
        public ActionResult Reengagement(CommunicationsContext context)
        {
            var member = _membersQuery.GetMember(context.UserId);

            if (member == null)
            {
                return(HttpNotFound());
            }

            var candidate = _candidatesQuery.GetCandidate(context.UserId);
            var resume    = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value);

            var model = CreateModel <ReengagementModel>(context);

            model.Member    = member;
            model.Candidate = candidate;

            if (!member.IsActivated)
            {
                // Create a new activation if needed.

                var emailAddress      = member.GetBestEmailAddress().Address;
                var emailVerification = _emailVerificationsQuery.GetEmailVerification(member.Id, emailAddress);
                if (emailVerification == null)
                {
                    emailVerification = new EmailVerification {
                        EmailAddress = emailAddress, UserId = member.Id
                    };
                    _emailVerificationsCommand.CreateEmailVerification(emailVerification);
                }

                model.ActivationCode = emailVerification.VerificationCode;
            }

            model.ProfilePercentComplete = _memberStatusQuery.GetPercentComplete(member, candidate, resume);
            var execution = _executeJobAdSearchCommand.SearchSuggested(member, null, new Range(0, MaxSuggestedJobCount));

            var jobAds = _jobAdsQuery.GetJobAds <JobAd>(execution.Results.JobAdIds).ToDictionary(j => j.Id, j => j);

            model.SuggestedJobs = (from i in execution.Results.JobAdIds
                                   where jobAds.ContainsKey(i)
                                   select jobAds[i]).ToList();

            model.JobSearch = GetJobSearchModel(member, candidate);

            var lastWeek = new DateTimeRange(DateTime.Today.AddDays(-7), DateTime.Today);

            model.TotalContactsLastWeek = _employerMemberAccessReportsQuery.GetMemberAccesses(lastWeek);

            var lastMonth = new DateTimeRange(DateTime.Today.AddMonths(-1), DateTime.Today);

            model.TotalContactsLastMonth = _employerMemberAccessReportsQuery.GetMemberAccesses(lastMonth);
            model.TotalViewed            = _employerMemberAccessReportsQuery.GetMemberViewings(context.UserId, lastMonth);

            return(View(model));
        }
Esempio n. 23
0
 public static EmailVerificationEntity Map(this EmailVerification emailVerification)
 {
     return(new EmailVerificationEntity
     {
         id = emailVerification.Id,
         createdTime = emailVerification.CreatedTime,
         emailAddress = emailVerification.EmailAddress,
         userId = emailVerification.UserId,
         verificationCode = emailVerification.VerificationCode
     });
 }
        public async Task SendVerificationCodeAsync(string email)
        {
            EmailVerification emailVerification = new EmailVerification()
            {
                Email            = email,
                ExpirationTime   = DateTime.Now.AddMinutes(5),
                VerificationCode = GenerateRandomNomber(1000, 9999)
            };

            await SaveVerificationcode(emailVerification);
            await SendEmailWithVerificationCodeAsync(emailVerification);
        }
Esempio n. 25
0
        public async Task <EmailVerificationModel> GetVerificationCodeAsync(string email)
        {
            EmailVerification emailVerification = await _userDbContext.EmailVerifications
                                                  .Where(verification => verification.Email == email)
                                                  .FirstOrDefaultAsync();

            if (emailVerification == null)
            {
                throw new VerificationCodeNotFoundException(email);
            }
            return(_mapper.Map <EmailVerificationModel>(emailVerification));
        }
Esempio n. 26
0
        public ActionResult signUp(signUp model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (NotesMarketPlaceEntities DBobj = new NotesMarketPlaceEntities())
                    {
                        Users u = new Users();
                        u.RoleID          = 1003;
                        u.FirstName       = model.FirstName;
                        u.LastName        = model.LastName;
                        u.EmailId         = model.EmailId;
                        u.Password        = model.Password;
                        u.IsEmailVerified = false;
                        u.CreatedDate     = DateTime.Now;
                        u.IsActive        = true;

                        DBobj.Users.Add(u);
                        DBobj.SaveChanges();

                        if (u.UserID > 0)
                        {
                            ModelState.Clear();
                            ViewBag.IsSuccess = "<p><span><i class='fas fa-check-circle'></i></span> Your account has been successfully created </p>";
                            TempData["name"]  = model.FirstName;


                            //  Email Verification Link
                            var activationCode = model.Password;
                            var verifyUrl      = "/User/VerifyAccount/" + activationCode;
                            var activationlink = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl);


                            // Sending Email
                            EmailVerification.SendVerifyLinkEmail(u, activationlink);
                            ViewBag.Title         = "NotesMarketPlace";
                            @TempData["UserName"] = model.FirstName.ToString();


                            return(RedirectToAction("emailverification", "User"));
                        }
                    }
                }

                return(View());
            }
            catch (Exception e)
            {
                return(View());
            }
        }
Esempio n. 27
0
        private ActivationEmail CreateActivationEmail(string emailAddress)
        {
            var emailVerification = new EmailVerification
            {
                CreatedTime      = DateTime.Now,
                EmailAddress     = emailAddress,
                Id               = Guid.NewGuid(),
                UserId           = _memberUser.Id,
                VerificationCode = "123"
            };

            return(new ActivationEmail(_memberUser, emailVerification));
        }
Esempio n. 28
0
        private void Validate(EmailVerification emailVerification)
        {
            emailVerification.Validate();

            // Check that another email verification does not already exist matching this one.

            var existingEmailVerification = _repository.GetEmailVerification(emailVerification.UserId, emailVerification.EmailAddress);

            if (existingEmailVerification != null)
            {
                throw new ApplicationException(string.Format("An email verification already exists for user '{0}' and email address '{1}'.", emailVerification.UserId, emailVerification.EmailAddress));
            }
        }
        public async Task <bool> UpdateVerificationCodeAsync(Services.Models.EmailVerification emailVerification)
        {
            EmailVerification oldEmailVerification = await _accountContext.EmailVerificationS.FirstOrDefaultAsync(
                e => e.Email == emailVerification.Email);

            if (emailVerification == null)
            {
                throw new AccountNotFoundException("we didn't find this email");    //which exception
            }
            oldEmailVerification.VerificationCode = emailVerification.VerificationCode;
            oldEmailVerification.ExpirationTime   = emailVerification.ExpirationTime;
            return(await _accountContext.SaveChangesAsync() > 0);
        }
Esempio n. 30
0
        public static EmailVerification VerifyEmail(string email)
        {
            //LightCoral
            EmailVerification response = EmailVerification.None;

            if (!string.IsNullOrWhiteSpace(email))
            {
                Regex reg = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                response = (reg.IsMatch(email))
                                        ? EmailVerification.True
                                        : EmailVerification.False;
            }
            return(response);
        }
Esempio n. 31
0
        public void Handler_ReturnsNullEmailVerification_WhenNotFound_ByTicket()
        {
            var ticket = FakeData.String();
            var emailVerification = new EmailVerification
            {
                Ticket = FakeData.String(),
            };
            var data = new[] { emailVerification }.AsQueryable();
            var query = new EmailVerificationBy(ticket);
            var dbSet = new Mock<DbSet<EmailVerification>>(MockBehavior.Strict).SetupDataAsync(data);
            var entities = new Mock<IReadEntities>(MockBehavior.Strict);
            var entitySet = new EntitySet<EmailVerification>(dbSet.Object, entities.Object);
            entities.Setup(x => x.Query<EmailVerification>()).Returns(entitySet);
            var handler = new HandleEmailVerificationByQuery(entities.Object);

            EmailVerification result = handler.Handle(query).Result;

            result.ShouldBeNull();
            entities.Verify(x => x.Query<EmailVerification>(), Times.Once);
        }