// GET: Authentifications public ActionResult Index() { if (Session["client"] != null) { Personnes client = Session["client"] as Personnes; List <Authentifications> moi = new List <Authentifications>(); foreach (Authentifications a in db.Authentifications) { if (a.email == client.email) { moi.Add(a); } } return(View(moi)); } else { if ((TempData["message"] as string) != "" && TempData["message"] != null) { ViewBag.message = TempData["message"]; } Authentifications auth = new Authentifications(); return(RedirectToAction("../Authentifications/Connexion", auth));; } }
private void button1_Click(object sender, EventArgs e) { if (Authentifier.currentUser != null && Authentifier.currentUser.login != null) { try { Authentifications usrm = db.Authentifications.Where(c => c.id_utilisateurs == Authentifier.currentUser.id_utilisateurs).First(); usrm.nom = nom_user.Text; usrm.login = login_user.Text; usrm.password = password_user.Text; if (!login_user.Text.Equals("") && !nom_user.Text.Equals("") && !password_user.Text.Equals(confirm_user.Text)) { MessageBox.Show("confirme password ne correspoend pas au premier password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!login_user.Text.Equals("") && !nom_user.Text.Equals("")) { usrm.password = helperClass.encrypt(password_user.Text); db.Entry(usrm).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); MessageBox.Show("Modification avec succes"); button2_Click(sender, e); } } } catch { MessageBox.Show("problem de modification"); } } }
public ActionResult compte(Authentifications ath) { var response = Request["g-recaptcha-response"]; string secretKey = "your secret key here"; var client = new WebClient(); var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response)); var obj = JObject.Parse(result); var status = (bool)obj.SelectToken("success"); ViewBag.Message = status ? "Google reCaptcha validation success" : "Google reCaptcha validation failed"; if (ModelState.IsValid) { using (Manage_BooksEntities1 ml = new Manage_BooksEntities1()) { ml.Authentifications.Add(ath); ml.SaveChanges(); ViewBag.Message = "Cette Compte est Bien Cree"; RedirectToAction("login"); } } return(View("login")); }
public ActionResult LogOff(Authentifications authentifications) { Session.Clear(); string message = "Vous êtes déconnecté"; return(RedirectToAction("../Authentifications/Connexion", message)); }
public ActionResult DeleteConfirmed(int id) { Authentifications authentifications = db.Authentifications.Find(id); db.Authentifications.Remove(authentifications); db.SaveChanges(); return(RedirectToAction("LogOff", "Authentifications")); }
public void remplirChampText(Authentifications user) { if (user != null) { Authentifier.currentUser = user; nom_user.Text = user.nom; login_user.Text = user.login; } }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { if (dataGridView1.CurrentRow.Index != -1) { int id_utilisateurs = Convert.ToInt32(dataGridView1.CurrentRow.Cells["id_user"].Value); user = db.Authentifications.Where(c => c.id_utilisateurs == id_utilisateurs).First(); Ajouter_Utilisateur userModif = new Ajouter_Utilisateur(); userModif.remplirChampText(user); userModif.Show(); } }
public ActionResult Edit([Bind(Include = "id_auth,email,mot_de_passe,statut")] Authentifications authentifications) { if (ModelState.IsValid) { db.Entry(authentifications).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.statut = new SelectList(db.Statuts, "id_statut", "statut", authentifications.statut); return(View(authentifications)); }
public ActionResult Create([Bind(Include = "id_personne,civilite,prenom,nom,adresse,telephone,date_naissance,client,participant")] Personnes personnes) { Authentifications auth = new Authentifications(); personnes.email = (string)Session["login"]; /*emailclient;*/ if (ModelState.IsValid) { personnes.client = 1; personnes.participant = 1; db.Personnes.Add(personnes); db.SaveChanges(); // on verifie que le client que l'on viens de creer existe dans la table "personnes" if (db.Personnes.Any(i => i.email == personnes.email)) { // on recupere l'objet personne qui correspond au client sous forme de liste List <Personnes> clients = new List <Personnes>(); foreach (Personnes p in db.Personnes.Include(p => p.Civilites).Include(p => p.OuisNons).Include(p => p.OuisNons1)) { if (p.email == personnes.email) { clients.Add(p); } } // on verifie l'unicité de l'email dans la BDD if (clients.Count == 1) { Personnes client = clients[0]; // on recupere toutes les infos dans la session Session["client"] = client; ViewBag.civilite = new SelectList(db.Civilites, "id_civilite", "civilite", personnes.civilite); ViewBag.client = new SelectList(db.OuisNons, "id_ouinon", "valeur", personnes.client); ViewBag.participant = new SelectList(db.OuisNons, "id_ouinon", "valeur", personnes.participant); return(RedirectToAction("../Voyages/Index")); } else { ViewBag.message = " Erreur aucune ou plusieurs personnes avec cet e-mail dans la BDD###"; return(RedirectToAction("../Voyages/Index")); } } else { ViewBag.message = "### Erreur pas de Personne correspondante dans la BDD ###"; return(RedirectToAction("../Voyages/Index")); } } return(RedirectToAction("../Voyages/Index")); }
private void button1_Click(object sender, EventArgs e) { Authentifications v = new Authentifications(); v.nom = nom_user.Text; v.login = login_user.Text; v.password = helperClass.encrypt(login_user.Text); db.Authentifications.Add(v); db.SaveChanges(); MessageBox.Show("Vous avez ajouter un nouveau utilisateur"); button2_Click(sender, e); }
public ActionResult Create([Bind(Include = "id_auth,email,mot_de_passe,statut")] Authentifications authentifications) { try { if (ModelState.IsValid) { if (authentifications.email == "" || authentifications.email == null || authentifications.mot_de_passe == "" || authentifications.mot_de_passe == null) { ViewBag.Message = "Veuillez insérer un identifiant et un mot de passe!"; ViewBag.statut = new SelectList(db.Statuts, "id_statut", "statut"); return(View(authentifications)); } else if (db.Personnes.Any(i => i.email == authentifications.email)) { ViewBag.Message4 = "Cette personne existe déjà dans notre base de données, veuillez utiliser un autre email ou contacter notre service clientèle ..."; ViewBag.statut = new SelectList(db.Statuts, "id_statut", "statut"); return(View(authentifications)); } else { authentifications.statut = 1; // forcing status = CLIENT (statut = 1) db.Authentifications.Add(authentifications); db.SaveChanges(); Session["login"] = authentifications.email; return(RedirectToAction("../Personnes/Create")); // create/personnes } } else { ViewBag.statut = new SelectList(db.Statuts, "id_statut", "statut"); return(View(authentifications)); } } catch (System.Data.Entity.Infrastructure.DbUpdateException) { ViewBag.Message2 = "Cet email est déjà enregistré dans la base de données, veuillez insérer un autre email s'il vous plaît..."; return(View(authentifications)); } //catch (System.Data.Entity.Validation.DbEntityValidationException) //{ // ViewBag.Message = "Veuillez insérer un identifiant et un mot de passe!"; // return View(authentifications); //} catch (Exception) { ViewBag.Message3 = "Unknown (yet) Error"; return(View(authentifications)); } }
// GET: Authentifications public ActionResult Index() { if (Session["login"] != null) { var authentifications = db.Authentifications.Include(a => a.Statuts); return(View(authentifications.ToList())); } else { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
// GET: Assurances public ActionResult Index() { if (Session["login"] != null) { return(View(db.Assurances.ToList())); } else //redirection vers connexion si pas connecté { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
// GET: Authentifications/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Authentifications authentifications = db.Authentifications.Find(id); if (authentifications == null) { return(HttpNotFound()); } return(View(authentifications)); }
// GET: Personnes public ActionResult Index() { if (Session["login"] != null) { var personnes = db.Personnes.Include(p => p.Civilites).Include(p => p.OuisNons).Include(p => p.OuisNons1); return(View(personnes.OrderBy(a => a.id_personne).ToList())); } else //redirection vers connexion si pas connecté { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
// GET: Dossiers public ActionResult Index() { if (Session["login"] != null) { var dossiers = db.Dossiers.Include(d => d.Raisons_Annulations).Include(d => d.Etats_Dossiers).Include(d => d.Personnes).Include(d => d.Voyages); return(View(dossiers.OrderBy(a => a.id_dossier).ToList())); } else //redirection vers connexion si pas connecté { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
// GET: Voyages public ActionResult Index() { if (Session["login"] != null) { var voyages = db.Voyages.Include(v => v.Agences).Include(v => v.Destinations); return(View(voyages.OrderBy(a => a.id_voyage).ToList())); } else //redirection vers connexion si pas connecté { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
// GET: Authentifications/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Authentifications authentifications = db.Authentifications.Find(id); if (authentifications == null) { return(HttpNotFound()); } ViewBag.statut = new SelectList(db.Statuts, "id_statut", "statut", authentifications.statut); return(View(authentifications)); }
public ActionResult login(Authentifications log) { if (ModelState.IsValid) { using (Manage_BooksEntities1 con = new Manage_BooksEntities1()) { var mk = con.Authentifications.Where(a => a.User_Name.Equals(log.User_Name) && a.Password_cle.Equals(log.Password_cle)).FirstOrDefault(); if (mk != null) { Session["UserId"] = mk.User_Name.ToString(); Session["Password"] = mk.Password_cle.ToString(); return(RedirectToAction("list")); } //ViewBag.Message = "Successfully Registration Done"; } } return(View(log)); }
// GET: Dossiers public ActionResult Index() { if (Session["client"] != null) { Personnes clientconnecte = Session["client"] as Personnes; List <Dossiers> mesdossiers = new List <Dossiers>(); foreach (Dossiers d in db.Dossiers) { if (d.client == clientconnecte.id_personne) { mesdossiers.Add(d); } } return(View(mesdossiers.OrderBy(a => a.id_dossier).ToList())); } else { string message = "Veuillez vous connecter pour acceder à cette page"; Authentifications auth = new Authentifications(); return(RedirectToAction("Connexion", "Authentifications", new { auth, message }));; } }
public ActionResult Connection(Authentifications auth) { if (Request.Form["f_login"] != "" && Request.Form["f_pass"] != "") { string login = Request.Form["f_login"]; string password = Request.Form["f_pass"]; auth.email = login; auth.mot_de_passe = password; Session["login"] = login; Session["password"] = password; auth.email = ""; auth.mot_de_passe = ""; return(RedirectToAction("../Voyages/Index")); } else { ViewBag.message = "ATTENTION \nIf you want to proceed you must fill out all required fields"; return(View("Connection", auth)); } }
public ActionResult Connexion(Authentifications auth) { try { if (Request.Form["f_login"] != "" && Request.Form["f_pass"] != "") { //on recupere identifiant et mdp entrés dans la page string login = Request.Form["f_login"]; string password = Request.Form["f_pass"]; //on aurait aussi pu faire ca : //auth.email = login; /*auth.mot_de_passe = password; */ //certains caracteres font bugger le champ mot de passe List <string> interdits = new List <string>() { "<", ">" }; foreach (string i in interdits) { if (password.Contains(i)) { ViewBag.message = "### Votre mot de passe ne doit pas contenir le caractère " + i + " ###"; return(View("Connexion", auth)); } } /* * liste complete des authentification */ var listauth = db.Authentifications; //on verifie que l'email existe en tant que login dans la table des authentifications if (listauth.Any(i => i.email == login)) { // on recupere l'objet authentification dans une liste List <Authentifications> listauth2 = new List <Authentifications>(); foreach (Authentifications a in listauth.ToList() as List <Authentifications> ) { if (a.email == login) { listauth2.Add(a); } } //on verifie que cet e-mail ne correspond qu'a un login dans la BDD if (listauth2.Count == 1) { // on recupere l'objet authentification Authentifications emailvalid = listauth2[0]; //on verifie que if (emailvalid.mot_de_passe == password) { // on veridfie que c'est bien un client qui se connecte if (emailvalid.Statuts.statut != "Client") { ViewBag.message = "### Veuillez utiliser un \"Compte client\" pour vous connecter à l'application pour les clients ###"; return(View("Connexion", auth)); } else { // on verifie que le client qui se connecte existe dans la table "personnes" if (db.Personnes.Any(i => i.email == emailvalid.email)) { // on recupere l'objet personne qui correspond au client sous forme de liste List <Personnes> clients = new List <Personnes>(); foreach (Personnes p in db.Personnes.Include(p => p.Civilites).Include(p => p.OuisNons).Include(p => p.OuisNons1)) { if (p.email == emailvalid.email) { clients.Add(p); } } // on verifie l'unicité de l'email dans la BDD if (clients.Count == 1) { Personnes client = clients[0]; // on recupere toutes les infos dans la session Session["login"] = emailvalid.email; Session["client"] = client; return(RedirectToAction("../Voyages/Index")); } else { ViewBag.message = " Erreur aucune ou plusieurs personnes avec cet e-mail dans la BDD###"; return(View("Connexion", auth)); } } else { ViewBag.message = "### Erreur pas de Personne correspondante dans la BDD ###"; return(View("Connexion", auth)); } } } else { ViewBag.message = "Mot de Passe incorrecte"; return(View("Connexion", auth)); } } else { ViewBag.message = "### Erreur plusieurs correspondances pour cet e-mail dans la base de données ###"; return(View("Connexion", auth)); } } else { ViewBag.message = "Ce compte n'existe pas, veuillez vous inscrire pour créer un compte ou corriger votre identifiant"; return(View("Connexion", auth)); } } else { ViewBag.message = "ATTENTION \n Vous devez entrer un mot de passe et un email!"; return(View("Connexion", auth)); } } catch (Exception erreur) { ViewBag.message = "#### Erreur de connexion inconnue ###" + "\n\n\t\t" + erreur; return(View("Connexion", auth)); } }
public ActionResult Connexion() { Authentifications qui = new Authentifications(); return(View("Connexion", qui)); }
public ActionResult Connexion(Authentifications auth) { Authentifications auth2 = new Authentifications(); try { if (Request.Form["f_login"] != "" && Request.Form["f_pass"] != "") { //on recupere identifiant et mdp entrés dans la page string login = Request.Form["f_login"]; string password = Request.Form["f_pass"]; //on aurait aussi pu faire ca : //auth.email = login; /*auth.mot_de_passe = password; */ //certains caracteres font bugger le champ mot de passe List <string> interdits = new List <string>() { "<", ">" }; foreach (string i in interdits) { if (password.Contains(i)) { ViewBag.message = "### Votre mot de passe ne doit pas contenir le caractère " + i + " ###"; return(View("Connexion", auth2)); } } /* * liste complete des authentification */ var listauth = db.Authentifications; //on verifie que l'email existe en tant que login dans la table des authentifications if (listauth.Any(i => i.email == login)) { // on recupere l'objet authentification dans une liste List <Authentifications> listauth2 = new List <Authentifications>(); foreach (Authentifications a in listauth.ToList() as List <Authentifications> ) { if (a.email == login) { listauth2.Add(a); } } //on verifie que cet e-mail ne correspond qu'a un login dans la BDD if (listauth2.Count == 1) { // on recupere l'objet authentification Authentifications emailvalid = listauth2[0]; //on verifie que if (emailvalid.mot_de_passe == password) { // on veridfie que c'est bien un client qui se connecte if (emailvalid.Statuts.statut == "Client") { ViewBag.message = "### Veuillez utiliser un \"Compte employé\" pour vous connecter à l'application BoVoyage Intranet ###"; return(View("Connexion", auth2)); } else if (emailvalid.Statuts.statut == "Commercial" || emailvalid.Statuts.statut == "Administrateur" || emailvalid.Statuts.statut == "Marketing") { Session["login"] = emailvalid.email; Session["statut"] = emailvalid.Statuts.statut; return(RedirectToAction("../Voyages/Index")); } else { ViewBag.message = "### Erreur statut ! Ni client Ni Employé! ###"; return(View("Connexion", auth2)); } } else { ViewBag.message = "Mot de Passe incorrecte"; return(View("Connexion", auth2)); } } else { ViewBag.message = "### Erreur plusieurs correspondances pour cet e-mail dans la base de données ###"; return(View("Connexion", auth2)); } } else { ViewBag.message = "Ce compte n'existe pas, veuillez vous inscrire pour créer un compte ou corrigez votre identifiant"; return(View("Connexion", auth2)); } } else { ViewBag.message = "Rentrez un mot de Passe et un E-mail pour vous connecter"; return(View("Connexion", auth2)); } } catch (Exception erreur) { ViewBag.message = "#### Erreur de connexion inconnue ###" + "\n\n\t\t" + erreur; return(View("Connexion", auth2)); } }
public ActionResult LogOff(Authentifications authentifications) { Session.Clear(); return(RedirectToAction("Index", "Voyages")); }