public ResidenteValidation() { RuleFor(u => EmailValidation.Validate(u.Email)) .Equal(true) .WithMessage("Um Email válido deve ser informado"); RuleFor(u => SenhaValidation.Validate(u.Senha)) .Equal(true) .WithMessage("Informe uma senha de 8 a 10 caracteres incluindo letras maiúsculas, minúsculas e números"); RuleFor(u => u.RepetirSenha) .Equal(u => u.Senha) .WithMessage("Senhas informadas são diferentes"); RuleFor(m => m.Nome) .NotEmpty() .NotNull() .WithMessage("Nome é obrigatório") .Length(1, 30) .WithMessage("Nome deve ter até 30 caracteres"); RuleFor(m => m.Crm) .NotNull() .NotNull() .Length(1, 10) .WithMessage("Crm é obrigatório"); RuleFor(r => r.AnoResidencia) .NotEmpty() .LessThanOrEqualTo(DateTime.Now.Year) .GreaterThan(1900) .WithMessage("Ano de residência válido é obrigatório"); }
public Status Post([FromBody] DriverInfo driver) { var emailValidator = new EmailValidation(); if (!emailValidator.IsValidEmail(driver.Email)) { return new Status { StatusCode = 2002, IsOk = false, Message = "Email is not valid" } } ; if (!this.usersDataAccessLayer.IsValidUserName(driver.UserName)) { return new Status { StatusCode = 2001, IsOk = false, Message = "UserName is not valid" } } ; this.usersDataAccessLayer.AddDriver(driver); return(new Status { StatusCode = 1000, IsOk = true, Message = "Your account is crated." }); }
public void Test_IncorrectEmails() { EmailValidation e = new EmailValidation("abc"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("Abc.example.com"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("*****@*****.**"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("*****@*****.**"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("A@b@[email protected]"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("a\"b(c)d,e:f;g<h>i[j\\k][email protected]"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); Assert.AreEqual(false, e.IsValid); }
public DocenteValidation() { RuleFor(u => EmailValidation.Validate(u.Email)) .Equal(true) .WithMessage("Um Email válido deve ser informado"); RuleFor(u => SenhaValidation.Validate(u.Senha)) .Equal(true) .WithMessage("Informe uma senha de 8 a 10 caracteres incluindo letras maiúsculas, minúsculas e números"); RuleFor(u => u.RepetirSenha) .Equal(u => u.Senha) .WithMessage("Senhas informadas são diferentes"); RuleFor(m => m.Nome) .NotEmpty() .NotNull() .WithMessage("Nome é obrigatório") .Length(1, 30) .WithMessage("Nome deve ter até 30 caracteres"); RuleFor(m => m.Crm) .NotNull() .NotNull() .Length(1, 10) .WithMessage("Crm é obrigatório"); RuleFor(d => d.TitUniversitaria) .NotEmpty() .NotNull() .WithMessage("Titulação universitária é obrigatória"); }
public RecepcionistaValidation() { RuleFor(u => EmailValidation.Validate(u.Email)) .Equal(true) .WithMessage("Email válido deve ser informado"); RuleFor(u => SenhaValidation.Validate(u.Senha)) .Equal(true) .WithMessage("Informe uma senha de 8 a 10 caracteres incluindo letras maiúsculas, minúsculas e números"); RuleFor(u => u.RepetirSenha) .Equal(u => u.Senha) .WithMessage("Senhas informadas são diferentes"); RuleFor(r => r.Nome) .NotNull() .NotEmpty() .WithMessage("Nome do(a) Recepcionista é obrigatório") .Length(1, 30) .WithMessage("Nome deve ter até 30 caracteres"); RuleFor(r => r.Nascimento) .NotEqual(new DateTime()) .WithMessage("Data de nascimento é obrigatória"); RuleFor(r => VerificarMaioridade(r.Nascimento)) .Equal(true) .WithMessage("Recepcionista não pode ser menor de idade"); }
private void btnRegister_Click(object sender, EventArgs e) { User user = new User() { Name = this.txbRegisterName.Text, Surname = this.txbRegisterSurname.Text, Email = this.txbRegisterEmail.Text, Password = this.txbRegisterPassword.Text, Phone = this.txbRegisterPhone.Text, Type = (int)UserTypeEnum.User, }; bool isValid = ValidationOperation <User> .ValidateOperation(user); bool IsUnique = EmailValidation.IsUniqueEmail(user); if (IsUnique) { if (isValid) { UserDAL userDAL = new UserDAL(); userDAL.Add(user); MessageBox.Show("Successfully Registered!"); this.Close(); } } else { MessageBox.Show("The email is already used."); } }
bool SendValidateEmailCode(EmailValidation emailValidation) { var senderEmail = new MailAddress("*****@*****.**", "Quick Order"); var receiverEmail = new MailAddress(emailValidation.Email, emailValidation.UserId.ToString()); var sub = "Validation Email Code"; var body = "<div><b>Code:</b>" + emailValidation.ValidationCode; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential("*****@*****.**", "jp84704tt") }; using (var mess = new MailMessage(senderEmail, receiverEmail) { IsBodyHtml = true, Subject = sub, Body = body }) { smtp.Send(mess); return(true); } }
public async Task <ActionResult <bool> > PostUser([FromBody] User user) { _context.Users.Add(user); await _context.SaveChangesAsync(); string validationcode = Guid.NewGuid().ToString().Substring(0, 5); var emailValidation = new EmailValidation() { Email = user.Email, ExpDate = DateTime.Now.AddMinutes(30), EmailValidationId = Guid.NewGuid(), UserId = user.UserId, ValidationCode = validationcode }; _context.EmailValidations.Add(emailValidation); await _context.SaveChangesAsync(); SendValidateEmailCode(emailValidation); return(true); //return CreatedAtAction("GetUser", new { id = user.UserId }, user); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid && EmailValidation.CheckEmail(model.Email)) { var user = new ApplicationUser { UserName = model.Username, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("CreateWorkerForApplicationUser", "Worker", user)); } AddErrors(result); } ViewBag.Email = "No E-mail exists with that address. Please enter valid e-mail."; // If we got this far, something failed, redisplay form return(View(model)); }
private void btnSignup_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtEmailNew.Text) || string.IsNullOrEmpty(txtPasswordNew.Text)) { MessageBox.Show("Bạn phải nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!EmailValidation.IsValid(txtEmailNew.Text)) { MessageBox.Show("Email không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtPasswordNew.Text.Equals(txtReEnterPassword.Text)) { // Insert Player PlayerBUS.Instance.InsertPlayerToDB(txtEmailNew.Text, txtPasswordNew.Text, 100); MessageBox.Show("Đăng ký thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // Insert Question DataTable dtPlayer = PlayerBUS.Instance.GetPlayer(txtEmailNew.Text, txtPasswordNew.Text); int idPlayer = dtPlayer.Rows[0].Field <int>("idPlayer"); string imageLocation = Application.StartupPath + "\\Resources\\" + images[0] + ".jpg"; QuestionBUS.Instance.InsertQuestionToDB(1, imageLocation, answers[0], idPlayer); } else { MessageBox.Show("Mật khẩu không khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public Status Post([FromBody] GuideInfo guide) { var emailValidator = new EmailValidation(); if (!emailValidator.IsValidEmail(guide.Email)) { return new Status { StatusCode = 2002, IsOk = false, Message = "Email is not valid" } } ; if (!this.dataAccessLayer.IsValidUserName(guide.UserName)) { return new Status { StatusCode = 2001, IsOk = false, Message = "UserName is not valid" } } ; var id = this.dataAccessLayer.AddGuide(guide); return(new Status { StatusCode = 1000, IsOk = true, Message = "Your account is crated." }); }
public void Test_Empty() { EmailValidation e = new EmailValidation(""); e.CheckEmailIdentifier(); Assert.AreEqual(false, e.IsValid); }
public async Task <ActionResult <bool> > ResendCode(string userId) { var user = _context.Users.Where(u => u.UserId.ToString() == userId).FirstOrDefault(); if (user != null) { string validationcode = Guid.NewGuid().ToString().Substring(0, 5); var emailValidation = new EmailValidation() { Email = user.Email, ExpDate = DateTime.Now.AddMinutes(30), EmailValidationId = Guid.NewGuid(), UserId = user.UserId, ValidationCode = validationcode }; _context.EmailValidations.Add(emailValidation); await _context.SaveChangesAsync(); SendValidateEmailCode(emailValidation); return(true); } return(false); }
private void ValidateModel(User user, string password) { // validate email if (!EmailValidation.IsEmailFormatValid(user.Email)) { throw new ValidationException($"Email '{user.Email}' is not valid"); } //// student must have tenant //if (user.RoleId.EqualsEnum(Roles.Student) && user.TenantId.IsNotSet()) // throw new ValidationException("Tenant is required"); // check that a valid role is provided if (!user.RoleId.IsInEnum <Roles>() || user.RoleId.ToEnum <Roles>() == Roles.Undefined) { throw new ValidationException("Role is required"); } // validate login type Validator.Required(user.LoginTypeId, "Login Type"); if (user.LoginTypeId.EqualsEnum(LoginTypes.Default)) { // check password for new users if (user.Id.IsNotSet() || !string.IsNullOrWhiteSpace(password)) { ValidateNewPassword(user, password); } } else { // check social media fields set ValidateForSocialMediaLogin(user); } }
public IActionResult EditFeedbackPost(FeedbackViewModel feedbackViewModel) { if (!CharacterLength.CheckLength(feedbackViewModel.Message)) { ViewData["Limit"] = CharacterLength.LimitNumber; return(View("CharacterLimit")); } if (!EmailValidation.CheckEmail(feedbackViewModel.Email)) { ViewData["Limit"] = FeedbackNumberPerEmail.LimitNumber; return(View("InvalidMail")); } try { string email = _feedbackService.UpdateFeedback(feedbackViewModel); if (email == null) { return(View("FeedbackNumber")); } return(RedirectToAction("Details", new { id = feedbackViewModel.Id })); } catch { return(View("ExceptionView")); } }
private Client(string apiKey, string username, string password, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options ?? GetDefaultOptions(); _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent(Client.UserAgent) .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (!string.IsNullOrEmpty(apiKey)) { _fluentClient.SetBearerAuthentication(apiKey); } if (!string.IsNullOrEmpty(username)) { _fluentClient.SetBasicAuthentication(username, password); } AccessManagement = new AccessManagement(_fluentClient); Alerts = new Alerts(_fluentClient); ApiKeys = new ApiKeys(_fluentClient); Batches = new Batches(_fluentClient); Blocks = new Blocks(_fluentClient); Bounces = new Bounces(_fluentClient); Campaigns = new Campaigns(_fluentClient); Categories = new Categories(_fluentClient); Contacts = new Contacts(_fluentClient); CustomFields = new CustomFields(_fluentClient); Designs = new Designs(_fluentClient); EmailActivities = new EmailActivities(_fluentClient); EmailValidation = new EmailValidation(_fluentClient); GlobalSuppressions = new GlobalSuppressions(_fluentClient); InvalidEmails = new InvalidEmails(_fluentClient); IpAddresses = new IpAddresses(_fluentClient); IpPools = new IpPools(_fluentClient); Lists = new Lists(_fluentClient); Mail = new Mail(_fluentClient); Segments = new Segments(_fluentClient); SenderIdentities = new SenderIdentities(_fluentClient); Settings = new Settings(_fluentClient); SpamReports = new SpamReports(_fluentClient); Statistics = new Statistics(_fluentClient); Subusers = new Subusers(_fluentClient); Suppressions = new Suppressions(_fluentClient); Teammates = new Teammates(_fluentClient); Templates = new Templates(_fluentClient); UnsubscribeGroups = new UnsubscribeGroups(_fluentClient); User = new User(_fluentClient); WebhookSettings = new WebhookSettings(_fluentClient); WebhookStats = new WebhookStats(_fluentClient); SenderAuthentication = new SenderAuthentication(_fluentClient); }
public void Validate() { if (CanValidate()) { var test = EmailValidation.Test(property.Value); SetStatus(test, ERROR_CODE.INVALID); } }
public IActionResult Validated(string email) { EmailValidation emailObject = new EmailValidation(); emailObject.Email = email; emailObject.ValidateEmail(email); return(View(emailObject)); }
public void IsValid_ValidEmail_ReturnsTrue() { var emailValidation = new EmailValidation(); var r = emailValidation.isValid("*****@*****.**"); Assert.AreEqual(r, true); }
public void IsValid_EmailNull_ReturnsFalse() { var emailValidation = new EmailValidation(); var r = emailValidation.isValid(null); Assert.AreEqual(r, false); }
public void SendMail(CustomerWebAccount customerWebAccount, EmailValidation emailValidation) { MailMessage mailMessage = new MailMessage("*****@*****.**", customerWebAccount.Email); mailMessage.Body = "blah blub: http://www.valkyra.de/api/CustomerRegister/validate/" + emailValidation.ValidationId; mailMessage.Subject = "Valkyra Shop Email validation Link"; smptClient.Send(mailMessage); }
public async Task <Result> ValidateEmail(EmailValidation emailValidation) { var(result, statusCode, message) = await _consumingApiHelper .AddBearerAuthentication(_apiKeyValidation) .PostAsync <EmailValidation, EmailInfo>("/validations/email", emailValidation); return(result.result); }
public RegisterPageViewModel(IMessageBoxService messageBoxService, IEventAggregator eventAggregator, IoCProxy ioc) : base(messageBoxService, eventAggregator, ioc) { AddValidationRule(() => Email).Condition(() => !EmailValidation.Check(Email)).Message("-"); AddValidationRule(() => Password).Condition(() => string.IsNullOrEmpty(Password)).Message("-"); AddValidationRule(() => RepeatPassword).Condition(() => string.IsNullOrEmpty(RepeatPassword)).Message("-"); AddValidationRule(() => FirstName).Condition(() => string.IsNullOrEmpty(FirstName)).Message("-"); AddValidationRule(() => Surname).Condition(() => string.IsNullOrEmpty(Surname)).Message("-"); }
private void btnGenNewPassword_Click(object sender, EventArgs e) { if (!EmailValidation.IsValid(txtEmailVerify.Text.Trim())) { MessageBox.Show("Email không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataTable dtPlayer = PlayerBUS.Instance.GetPlayerByEmail(txtEmailVerify.Text); if (dtPlayer.Rows.Count != 0) { // Phát sinh ngẫu nhiên mật khẩu mới var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var stringChars = new char[8]; var random = new Random(); for (int i = 0; i < stringChars.Length; i++) { stringChars[i] = chars[random.Next(chars.Length)]; } string newPassword = new String(stringChars); // Không cho phép tạo mật khẩu mới nhiều lần btnGenNewPassword.Enabled = false; try { MailMessage msg = new MailMessage(); msg.From = new MailAddress("*****@*****.**"); msg.To.Add(txtEmailVerify.Text); msg.Subject = "Thông báo Bảo mật quan trọng"; msg.Body = "Mật khẩu mới của bạn : " + newPassword; SmtpClient smt = new SmtpClient(); smt.Host = "smtp.gmail.com"; System.Net.NetworkCredential ntcd = new NetworkCredential(); ntcd.UserName = "******"; ntcd.Password = "******"; smt.Credentials = ntcd; smt.EnableSsl = true; smt.Port = 587; smt.Send(msg); MessageBox.Show("Mật khẩu mới của bạn được gửi về Email của bạn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); PlayerBUS.Instance.UpdatePassword(txtEmailVerify.Text, newPassword); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Email không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Initializes a new instance of the <see cref="BaseClient" /> class. /// </summary> /// <param name="apiKey">Your api key.</param> /// <param name="httpClient">Allows you to inject your own HttpClient. This is useful, for example, to setup the HtppClient with a proxy.</param> /// <param name="disposeClient">Indicates if the http client should be dispose when this instance of BaseClient is disposed.</param> /// <param name="options">Options for the SendGrid client.</param> /// <param name="logger">Logger.</param> public BaseClient(string apiKey, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options; _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)") .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Remove all the built-in formatters and replace them with our custom JSON formatter _fluentClient.Formatters.Clear(); _fluentClient.Formatters.Add(new JsonFormatter()); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException(apiKey); } _fluentClient.SetBearerAuthentication(apiKey); AccessManagement = new AccessManagement(FluentClient); Alerts = new Alerts(FluentClient); ApiKeys = new ApiKeys(FluentClient); Batches = new Batches(FluentClient); Blocks = new Blocks(FluentClient); Bounces = new Bounces(FluentClient); Designs = new Designs(FluentClient); EmailActivities = new EmailActivities(FluentClient); EmailValidation = new EmailValidation(FluentClient); GlobalSuppressions = new GlobalSuppressions(FluentClient); InvalidEmails = new InvalidEmails(FluentClient); IpAddresses = new IpAddresses(FluentClient); IpPools = new IpPools(FluentClient); Mail = new Mail(FluentClient); Settings = new Settings(FluentClient); SpamReports = new SpamReports(FluentClient); Statistics = new Statistics(FluentClient); Subusers = new Subusers(FluentClient); Suppressions = new Suppressions(FluentClient); Teammates = new Teammates(FluentClient); Templates = new Templates(FluentClient); UnsubscribeGroups = new UnsubscribeGroups(FluentClient); User = new User(FluentClient); WebhookSettings = new WebhookSettings(FluentClient); WebhookStats = new WebhookStats(FluentClient); SenderAuthentication = new SenderAuthentication(FluentClient); }
public void Test_ShouldStartWithALetter() { EmailValidation e = new EmailValidation("*****@*****.**"); e.CheckEmailIdentifier(); Assert.AreEqual(false, e.IsValid); e = new EmailValidation("*****@*****.**"); e.CheckEmailIdentifier(); Assert.AreEqual(true, e.IsValid); }
public EmailValidation CreateValidationLink(CustomerWebAccount customerWebAccount) { EmailValidation _emailValidation = new EmailValidation(); _emailValidation.Created = DateTime.Now; _emailValidation.CustomerWebAccount = customerWebAccount; _emailValidation.ExpiredDate = DateTime.Now.AddDays(7); _emailValidation.ValidationId = Guid.NewGuid(); _dbContext.EmailValidations.Add(_emailValidation); _dbContext.SaveChanges(); return(_emailValidation); }
public Employee(string name, string email, Departament departament) { GenericValidation.StringIsNullOrEmpty(name, EXCEPTION_MESSAGE_EMPLOYEE_NAME_REQUIRED); GenericValidation.StringIsNullOrEmpty(email, EXCEPTION_MESSAGE_EMPLOYEE_EMAIL_REQUIRED); EmailValidation.IsValid(email); GenericValidation.ObjectIsNull(departament, EXCEPTION_MESSAGE_EMPLOYEE_DEPARTAMENT_REQUIRED); Name = name; Email = email; DepartamentId = departament.Id; Departament = departament; }
private void ValidateEmail(bool unique = false) { var emailValidation = new EmailValidation(_repository); RuleFor(c => c.email) .NotEmpty().WithMessage("'Email' não pode ser vazio.") .EmailAddress().WithMessage("Email inválido."); if (unique) { RuleFor(c => c.email).Must(emailValidation.IsUnique).WithMessage("O Email já esta em uso."); } }
public void Test_WebServiceMock() { using (var objClient = new System.Net.WebClient()) { var strFile = objClient.DownloadString("http://freegeoip.app/json/42.42.42.42"); string countrycode = strFile.Substring(strFile.IndexOf("country_code")).Split(',')[0].Split('"')[2]; EmailValidation e = new EmailValidation("*****@*****.**"); e.CheckEmailIdentifier(); e.CheckEmailDomains(); e.IsSpam(countrycode); Assert.AreEqual(false, e.IsValid); } }