public void SendMail()
 {
     if (_plantenDataService.getGebruikerViaEmail(EmailInput) != null)
     {
         if (CodeInput != null)
         {
             CodeInput = null;
         }
         Random r = new Random();
         for (int i = 0; i < 9; i++)
         {
             CodeInput += r.Next(0, 9).ToString();
         }
         string fileName = "MailMessage.html";
         string path     = Environment.CurrentDirectory.Replace("\\bin\\Debug\\netcoreapp3.1", "") + $"\\MailService\\Files\\{fileName}";
         string html     = File.ReadAllText(path);
         string body     = String.Format(html, CodeInput);
         var    msg      = sMTPMailService.CreateMail(EmailInput, body, "Wachtwoord reset");
         var    result   = sMTPMailService.sendMessage(msg);
         if (result.Status == MailSendingStatus.OK)
         {
             MessageBox.Show($"Message send to {EmailInput}");
             EmailEnabled = false;
             CodeEnabled  = true;
             return;
         }
         else
         {
             MessageBox.Show(result.Message);
             return;
         }
     }
     else
     {
         MessageBox.Show("Deze mail bestaat niet in onze database.");
     }
 }
Beispiel #2
0
 //hemen & maarten
 public void addGebruiker(Window closeWindow)
 {
     try
     {
         if (EmailInput != null && VoorNaamInput != null && AchterNaamInput != null && VivesNrInput != null)
         {
             if (EmailInput.Contains("vives.be") && EmailInput.Contains("@"))
             {
                 var gebruiker = _dataservice.getGebruikerViaEmail(EmailInput);
                 if (gebruiker == null)
                 {
                     if (WachtwoordBevestigen == WachtwoordInput)
                     {
                         using (var sha256 = SHA256.Create())
                         {
                             GebruikersBeheer beheer = new GebruikersBeheer(LoggedInGebruiker);
                             var hashedBytes         = sha256.ComputeHash(Encoding.UTF8.GetBytes(WachtwoordInput));
                             _dataservice.addGebruiker(SelectedRol.Omschrijving, EmailInput, hashedBytes, VoorNaamInput, AchterNaamInput, VivesNrInput);
                             closeWindow.Close();
                             beheer.ShowDialog();
                         }
                     }
                     else
                     {
                         SelectedError = "wachtwoord is niet hetzelfde";
                     }
                 }
                 else
                 {
                     SelectedError = "Het emailadres bestaat al";
                 }
             }
             else
             {
                 SelectedError = "Het emailadres moet 'vives.be' bevatten";
             }
         }
         else
         {
             SelectedError = "Er zijn velden niet ingevuld";
         }
     }
     catch (Exception)
     {
         SelectedError = "oei, er is iets fout";
     }
 }
Beispiel #3
0
 //Maarten &Hemen
 private void CloseWindow(Window windowClose)
 {
     try
     {
         if (EmailInput != null && WachtwoordInput != null)
         {
             using (var sha256 = SHA256.Create())
             {
                 var gebruiker = _plantenDataService.getGebruikerViaEmail(EmailInput);
                 if (gebruiker != null)
                 {
                     var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(WachtwoordInput));
                     if (hashedBytes.SequenceEqual(gebruiker.HashPaswoord))
                     {
                         MainWindow window = new MainWindow(gebruiker);
                         windowClose.Close();
                         window.ShowDialog();
                     }
                     else
                     {
                         SelectedError = "Wachtwoord is onjuist";
                     }
                 }
                 else
                 {
                     SelectedError = "Emailadres of wachtwoord is niet gekend";
                 }
             }
         }
         else
         {
             SelectedError = "Er is een veld niet ingevuld";
         }
     }
     catch (Exception e)
     {
         SelectedError = "er is iets mis. Check uw paswoord of emailadres";
     }
 }