/// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public bool Send(IMemberShipFactory daoFactory)
        {
            if (daoFactory == null)
            {
                throw new ArgumentNullException("daoFactory");
            }
            if (String.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id", "Id is empty");
            }
            User myUsers = daoFactory.CreateUserDao().Get(Id);

            if (myUsers == null)
            {
                throw new ArgumentException("Id", String.Format("can not find any use with id={0}", Id));
            }
            EmailVerifier token = myUsers.Contact.VerifyEmail(30, daoFactory);

            var deleage = new CreateVariablesHandler(user => new Dictionary <string, string>
            {
                { "name", user.Name },
                { "parameters", token.CreateQueryString() }
            });

            OrnamentContext.Configuration.MessagesConfig.VerifyEmailAddress.Publish(daoFactory, deleage, myUsers);

            daoFactory.CreateUserDao().SaveOrUpdate(myUsers);
            return(true);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Login(AdminLogin model)
        {
            var username = model.Usuario.ToUpperInvariant().Trim();

            var usuario = await this._context.Administradores.Where(a => a.Estado)
                          .Include(a => a.Rol)
                          .FirstOrDefaultAsync(a => a.Estado && EmailVerifier.IsValid(username) ? a.Email == username : a.Username == username)
                          .ConfigureAwait(false);

            if (usuario == null)
            {
                return(this.NotFound());
            }

            if (!this._passwordHelper.VerificarPasswordHash(model.Password, usuario.PasswordHash))
            {
                return(this.NotFound());
            }

            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.NameIdentifier, usuario.Id.ToString(CultureInfo.InvariantCulture)),
                new Claim(ClaimTypes.Email, usuario.Email),
                new Claim(ClaimTypes.Role, usuario.Rol.Nombre),
                new Claim("Id", usuario.Id.ToString(CultureInfo.InvariantCulture)),
                new Claim("Rol", usuario.Rol.Nombre),
                new Claim("Username", usuario.Username),
            };

            return(this.Ok(
                       new { token = this._tokenHelper.GenerarToken(claims, 60 * 24 * 4) }
                       ));
        }
Exemplo n.º 3
0
            /// <summary>
            ///     Veirfy Email
            /// </summary>
            /// <param name="expireMiniutes"></param>
            /// <param name="daoFactory"></param>
            /// <returns></returns>
            public virtual EmailVerifier VerifyEmail(int expireMiniutes, IMemberShipFactory daoFactory)
            {
                var dao    = daoFactory.CreateEmailVerifierDao();
                var result = new EmailVerifier(User, expireMiniutes, VerifyType.Email);

                dao.SaveOrUpdate(result);
                EmailVerified = false;
                return(result);
            }
        // GET: EmailChecker
        public ActionResult Index()
        {
            // bool value = true;
            using (EmailVerifier obj = new EmailVerifier())
            {
                // bool result = verifier.CheckExists(EmailText.Text);
                // bool output = obj.IsEmailVerified("*****@*****.**");
            }

            return(View());
        }
Exemplo n.º 5
0
            public virtual EmailVerifier ResetPassword(IMemberShipFactory daoFactory, int expireMiniutes)
            {
                if (daoFactory == null)
                {
                    throw new ArgumentNullException("daoFactory");
                }
                if (expireMiniutes <= 0)
                {
                    expireMiniutes = 30;
                }
                var result = new EmailVerifier(User, expireMiniutes, VerifyType.ResetPassword);

                daoFactory.CreateEmailVerifierDao().SaveOrUpdate(result);
                return(result);
            }
        // POST: api/EmailVerifier
        public MXServer PostEmail(MXServer Server)
        {
            MXServer newObj = new MXServer();

            if (Server.Email != null)
            {
                using (EmailVerifier obj = new EmailVerifier())
                {
                    // bool result = verifier.CheckExists(EmailText.Text);
                    newObj = obj.IsEmailVerified(Server.Email);
                }
            }

            return(newObj);
        }
Exemplo n.º 7
0
        public VerifyResult Save(IMemberShipFactory factory)
        {
            EmailVerifier userToken = factory.CreateEmailVerifierDao().Get(Id);

            if (userToken == null)
            {
                return(VerifyResult.NotFoundTokenId);
            }
            if (userToken.Verify(TokenId, factory) == VerifyResult.Success)
            {
                userToken.Account.Security.ChangePassword(PasswordModel.NewPassword);
                factory.CreateUserDao().Update(userToken.Account);
                return(VerifyResult.Success);
            }
            return(VerifyResult.Failed);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var email = value as string;

            if (email != null)
            {
                if (Dns.GetHostName().ToUpper() != "DSVR017757")
                {
                    return(ValidationResult.Success);
                }

                var verifier = new EmailVerifier();
                var result   = verifier.Verify(email, VerificationLevel);
                if (result.IsSuccess)
                {
                    return(ValidationResult.Success);
                }
            }
            return(new ValidationResult(FormatErrorMessage(validationContext.DisplayName)));
        }
Exemplo n.º 9
0
        public ActionResult RetrievePassword(string id, string token)
        {
            EmailVerifier userToken = _factory.CreateEmailVerifierDao().Get(id);

            if (userToken == null)
            {
                return(View("~/Views/HttpErrors/404.cshtml"));
            }
            var result = userToken.Verify(token);

            ViewData["VerifyResult"] = result;

            var model = new ResetPasswordModel
            {
                Id      = id,
                TokenId = token
            };

            return(View(model));
        }
Exemplo n.º 10
0
        public ActionResult VerifyEmail(string id, string token)
        {
            EmailVerifier userToken = _factory.CreateEmailVerifierDao().Get(id);

            try
            {
                if (userToken == null)
                {
                    return(View("~/Views/HttpErrors/404.cshtml"));
                }
                var verifyEmailModel = new VerifyEmailModel(userToken);
                return(View(verifyEmailModel.Verify(OrnamentContext.MemberShip.CurrentUser(), token, _factory)));
            }
            finally
            {
                if (userToken != null)
                {
                    _factory.CreateEmailVerifierDao().SaveOrUpdate(userToken);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        public RetrievePasswordResult Retrieve(IMemberShipFactory daoFactory)
        {
            User user = daoFactory.CreateUserDao().GetByLoginId(AccountOrEmail) ??
                        daoFactory.CreateUserDao().GetUserByEmail(AccountOrEmail);

            if (user == null)
            {
                return(RetrievePasswordResult.NotExistAccountOrEmail);
            }

            EmailVerifier emailToken = user.Security.ResetPassword(daoFactory, 50);
            var           direct     = new Dictionary <string, string>
            {
                { "name", user.Name },
                { "loginId", user.LoginId },
                { "parameters", emailToken.CreateQueryString() }
            };

            OrnamentContext.Configuration.MessagesConfig.RetrivePassword.Publish(daoFactory, direct, user);
            return(RetrievePasswordResult.Success);
        }
Exemplo n.º 12
0
 public EmailVerifyResult VerifyEmail(string email)
 {
     Logger.Log.Trace("VerifyEmail called.");
     return(EmailVerifier.VerifyAsync(email));
 }
Exemplo n.º 13
0
 /// <summary>
 /// </summary>
 /// <param name="emailVerifier"></param>
 public VerifyEmailModel(EmailVerifier emailVerifier)
 {
     _emailVerifier = emailVerifier;
     Id = _emailVerifier.Id;
 }
Exemplo n.º 14
0
 private void validateEmail(DataRow row)
 {
     string email = row["Email"].ToString().Trim();
     try
     {
         MailAddress m = new MailAddress(email);
         // Khong kiem tra voi yahoo mail.
         if (!m.Host.ToLower().Equals("yahoo.com")
             && !m.Host.ToLower().Equals("yahoo.com.vn"))
         {
             string text = "Scan: " + email;
             logs_scan.Info(text); //lblInfo.Text = text;
             EmailVerifier verify = new EmailVerifier(true);
             bool rs = verify.CheckExists(email);
             if (!rs)
             {
                 // Xoa va sao luu khach hang nay.
                 deleteAndBackupCustomer(row);
                 text = "Scan-Fail: " + email;
                 logs_scan.Info(text); //lblInfo.Text = text;
             }
             else
             {
                 text = "Scan-OK: " + email;
                 logs_scan.Info(text); //lblInfo.Text = text;
             }
         }
     }
     catch (Exception ex)
     {
         // Xoa va sao luu khach hang nay.
         deleteAndBackupCustomer(row);
         logs_scan.Info("Scan-Error: " + email, ex);
     }
 }
Exemplo n.º 15
0
    private string checkInputCustomer()
    {
        verify = new EmailVerifier(true);
        string message = "";
        if (txtName.Text == "")
        {
            message = "Bạn chưa nhập tên khách hàng!";
            this.txtName.Focus();
        }
        else if (txtBirthday.Text == "")
        {
            message = "Bạn chưa nhập ngày sinh!";
            this.txtBirthday.Focus();
        }
        else if (txtEmail.Text == "")
        {
            message = "Bạn chưa nhập Email khách hàng!";
            this.txtEmail.Focus();
        }
        else if (EmailTools.IsEmail(txtEmail.Text.Trim().ToString()) == false)
        {
            message = "Bạn nhập không đúng định dạng Email!";
            this.txtEmail.Focus();
        }

        else if (drlMailGroup.SelectedValue == null)
        {
            message = "Bạn chưa chọn nhóm mail!";
            this.drlMailGroup.Focus();
        }
        //else if (verify.CheckExists(txtEmail.Text) == false)
        //{
        //    message = "Địa chỉ mail không tồn tại";
        //    this.txtEmail.Focus();
        //}
        else
        {
            message = checkCreateCustomer(1);
        }
        return message;
    }
Exemplo n.º 16
0
 public EmailValidator(string CobisiRunTimeKey)
 {
     EmailVerifier.RuntimeLicenseKey = CobisiRunTimeKey;
     CobisiVerifier = new EmailVerifier();
 }
Exemplo n.º 17
0
 /// <summary>
 /// </summary>
 /// <param name="emailVerifier"></param>
 public VerifyEmailModel(EmailVerifier emailVerifier)
 {
     _emailVerifier = emailVerifier;
     Id             = _emailVerifier.Id;
 }