diff --git a/Style/signInStyle.css b/Style/signInStyle.css new file mode 100644 index 0000000..21c3fa1 --- /dev/null +++ b/Style/signInStyle.css @@ -0,0 +1,178 @@ +@import url('https://fonts.googleapis.com/css?family=Raleway:400,700'); + +* { + box-sizing: border-box; + margin: 0; + padding: 0; + font-family: Raleway, sans-serif; +} + +body { + background: linear-gradient(90deg, #C7C5F4, #776BCC); +} + +.container { + display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; +} + +.screen { + background: linear-gradient(90deg, #5D54A4, #7C78B8); + position: relative; + height: 600px; + width: 360px; + box-shadow: 0px 0px 24px #5C5696; +} + +.screen__content { + z-index: 1; + position: relative; + height: 100%; +} + +.screen__background { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 0; + -webkit-clip-path: inset(0 0 0 0); + clip-path: inset(0 0 0 0); +} + +.screen__background__shape { + transform: rotate(45deg); + position: absolute; +} + +.screen__background__shape1 { + height: 520px; + width: 520px; + background: #FFF; + top: -50px; + right: 120px; + border-radius: 0 72px 0 0; +} + +.screen__background__shape2 { + height: 220px; + width: 220px; + background: #6C63AC; + top: -172px; + right: 0; + border-radius: 32px; +} + +.screen__background__shape3 { + height: 540px; + width: 190px; + background: linear-gradient(270deg, #5D54A4, #6A679E); + top: -24px; + right: 0; + border-radius: 32px; +} + +.screen__background__shape4 { + height: 400px; + width: 200px; + background: #7E7BB9; + top: 420px; + right: 50px; + border-radius: 60px; +} + +.login { + width: 320px; + padding: 30px; + padding-top: 156px; +} + +.login__field { + padding: 20px 0px; + position: relative; +} + +.login__icon { + position: absolute; + top: 30px; + color: #7875B5; +} + +.login__input { + border: none; + border-bottom: 2px solid #D1D1D4; + background: none; + padding: 10px; + padding-left: 24px; + font-weight: 700; + width: 75%; + transition: .2s; +} + +.login__input:active, +.login__input:focus, +.login__input:hover { + outline: none; + border-bottom-color: #6A679E; +} + +.login__submit { + background: #fff; + font-size: 14px; + margin-top: 30px; + padding: 16px 20px; + border-radius: 26px; + border: 1px solid #D4D3E8; + text-transform: uppercase; + font-weight: 700; + display: flex; + align-items: center; + width: 100%; + color: #4C489D; + box-shadow: 0px 2px 2px #5C5696; + cursor: pointer; + transition: .2s; +} + +.login__submit:active, +.login__submit:focus, +.login__submit:hover { + border-color: #6A679E; + outline: none; +} + +.button__icon { + font-size: 24px; + margin-left: auto; + color: #7875B5; +} + +.social-login { + position: absolute; + height: 140px; + width: 160px; + text-align: center; + bottom: 0px; + right: 0px; + color: #fff; +} + +.social-icons { + display: flex; + align-items: center; + justify-content: center; +} + +.social-login__icon { + padding: 20px 10px; + color: #fff; + text-decoration: none; + text-shadow: 0px 0px 8px #7875B5; +} + +.social-login__icon:hover { + transform: scale(1.5); +} \ No newline at end of file diff --git a/Vues/accueil.php b/Vues/accueil.php index b0c9c92..99a37df 100644 --- a/Vues/accueil.php +++ b/Vues/accueil.php @@ -27,9 +27,6 @@ @@ -42,10 +39,13 @@ + ?>
  • -
    getName(); ?>
    - +
    getName(); ?>
    +
    + + +
  • getCreator()!=null){ if ($dataView[0]->getPrivate()){ ?> - +
    + + +
    - + ?> + +
    + + +
    @@ -89,19 +98,35 @@ getCompleted()){ ?> - +
    + + + +
    - - +
    + + + +
    - - - +
    + + + +
    + +
    + + + +
    @@ -109,7 +134,10 @@ } ?>
  • - +
    + + +
  • diff --git a/Vues/signIn.php b/Vues/signIn.php new file mode 100644 index 0000000..53a097d --- /dev/null +++ b/Vues/signIn.php @@ -0,0 +1,45 @@ + + + + Slide Navbar + + + + + +
    +
    +
    + + +
    +
    + + + + +
    +
    +
    + + diff --git a/Vues/signUp.php b/Vues/signUp.php index 4e11af9..e9c77fe 100644 --- a/Vues/signUp.php +++ b/Vues/signUp.php @@ -3,36 +3,47 @@ Slide Navbar - + - -
    - - -
    -
    - - - - -
    +
    +
    +
    + + - - - - - - +
    +
    + + + + +
    - - \ No newline at end of file +
    + + diff --git a/config/Validation.php b/config/Validation.php index 32e46ce..228b58d 100644 --- a/config/Validation.php +++ b/config/Validation.php @@ -2,24 +2,66 @@ class Validation{ - static function val_action($action){ - if (!isset($action)){ - throw new Exceptionb('Pas d\'action'); - } - } + static function val_connexion($usrName,$mdp,$dataVueEreur) { + if (!isset($usrName)||$usrName=="") { + $dataVueEreur[] ="Username or password missing"; + } + if ($usrName != Validation::clear_string($usrName)){ + $dataVueEreur[] = "Forbidden characters"; + $usrName=""; + } + if (!isset($mdp)||$mdp=="") { + $dataVueEreur[] ="Username or password missing"; + } + if($mdp != Validation::clear_string($mdp)){ + $dataVueEreur[] = "Forbidden characters"; + $mdp=""; + } + return $dataVueEreur; + } - static function val_form(string &$chaine, array &$dVueErreur){ + static function val_inscription($username,$pwd1,$pwd2,$dataVueEreur){ + if (!isset($username)||$username==="") { + $dataVueEreur[] ="All fields are required"; + } + if($username != Validation::clear_string($username)){ + $dataVueEreur[] = "Forbidden characters"; + $username=""; + } + if (!isset($pwd1)||$pwd1==="") { + $dataVueEreur[] ="All fields are required"; + } + if($pwd1 != Validation::clear_string($pwd1)){ + $dataVueEreur[] = "Forbidden characters"; + $pwd1=""; + } + if (!isset($pwd2)||$pwd2==="") { + $dataVueEreur[] ="All fields are required"; + } + if($pwd2 != Validation::clear_string($pwd2)){ + $dataVueEreur[] = "Forbidden characters"; + $pwd2=""; + } + if($pwd1 !== $pwd2){ + $dataVueEreur[]="Invalid confirmation"; + } + return $dataVueEreur; + } - if (!isset($chaine)||$chaine==""){ - $dVueErreuR[] = "pas de chaine de charactère"; - $chaine=""; + static function val_intitule($name, $dataVueEreur){ + if (!isset($name)||$name==="") { + $dataVueEreur[] ="Intitulé manquant"; + } + if($name != Validation::clear_string($name)){ + $dataVueEreur[] = "Forbidden characters"; + $name=""; } + return $dataVueEreur; + } - if (!$chaine != filter_var($chaine, FILTER_SANITIZE_STRING)){ - $dVueErreur[] = "tentative d'injection de code (attaque sécurité)"; - $chaine=""; - } - } + static function clear_string($champ){ + return filter_var($champ, FILTER_SANITIZE_STRING); + } } ?> \ No newline at end of file diff --git a/config/config.php b/config/config.php index 7f9fc13..e669aa8 100644 --- a/config/config.php +++ b/config/config.php @@ -4,10 +4,10 @@ $rep = __DIR__ . '/../'; //$location = "Location : http://londres.uca.local/" Finir le chemin du public_html -$base="dbthchazot1"; //nom bdd -$login="thchazot1"; -$password="achanger"; -$dsn="mysql:host=localhost;dbname=dbthchazot1"; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut) +$base="bddDeQualite"; //nom bdd +$login="root"; +$password="root"; +$dsn="mysql:host=localhost;port=8888;dbname=bddDeQualite"; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut) $vues['erreur'] = 'Vues/erreur.php'; diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 275173d..dbf2f86 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -1,29 +1,26 @@ Reinit(); break; case "connexion": - $this->ValidationFormulaireLogin($dVueEreur); $this->Connexion($login, $mdp); break; case "inscription": - $this->ValidationFormulaireLogin($dVueEreur); $this->Inscription($login, $mdp); break; @@ -39,52 +39,62 @@ class visitorController { } } - function Reinit() { - global $rep,$vues; - $dVue = array ( - 'username' => "", - 'password' => "", - ); - require ($rep.$vues['accueil']); + public function Reinit(){ + global $rep,$vues,$dataView,$styles; + $model = new MdlListe(); + $dataView = $model->getPublicList(); + require($rep.$vues['accueil']); + $vues_erreur= array(); } - function ValidationFormulaireLogin(array $dVueEreur){ - - global $rep, $vues; - $username = $_POST['username']; - $mdp = $_POST['password']; - - Validation::val_form($username, $mdp, $dVueEreur); - - $dVue = array ( - 'username' => $username, - 'password' => $mdp, - ); - require ($rep.$vues['accueil']); // - } - - - function Inscription($username, $mdp){ - $results = $this->$mdlUsr->insert($username, $mdp); - if($results != NULL) { - $_SESSION['username'] = $username; - $user = $this->$mdlUsr->getUserForConnection($username, $mdp); - require ($rep.$vues['accueil']); - return login ($rep.$vues['connexion']); + public function Inscription(array $vues_erreur){ + global $rep,$vues,$dataView; + $username=$_POST['username']; + $password=$_POST['password']; + $confirm=$_POST['passwordconf']; + $model = new MdlUser(); + $vues_erreur=Validation::val_inscription($username,$password,$confirm,$vues_erreur); + if($model->existUser($username)){ + $vues_erreur[]="Username already taken"; } + if(empty($vues_erreur)){ + $hash= password_hash($password,PASSWORD_DEFAULT); + $model->singUp($username,$hash); + $vues_erreur= array(); + } + else{ + require($rep.$vues['singUp']); + } + $_REQUEST['action']=null; + $this->reinit(); } - function Connexion($username, $mdp){ - $user = $this->$mdlUsr->getUserForConnection($username, $mdp); - if($user != NULL) { - $_SESSION['username'] = $username; - require ($rep.$vues['accueil']); - return $username; + public function Connexion(array $vues_erreur){ + global $rep,$vues,$dataView; + $username=$_POST['login']; + $password=$_POST['mdp']; + $vues_erreur=Validation::val_connexion($username,$password,$vues_erreur); + if(!empty($vues_erreur)){ + require($rep.$vues['signIn']); + } + $model= new MdlUser(); + if($model->existUser($username)){ + if(password_verify($password,$model->getPasswordHash($username))){ + $model->connexion($username); + $_REQUEST['action']=null; + $this->reinit(); + $vues_erreur= array(); + } + else{ + $vues_erreur =array('username'=>$username,'password'=>$password); + require($rep.$vues['signIn']); + } } - else { - require ($rep.$vues['connexion']); + else{ + $vues_erreur =array('username'=>$usrname,'password'=>$pwd); + require($rep.$vues['signIn']); } } } diff --git a/gateway/ListeGateway.php b/gateway/ListeGateway.php index 4e16a09..edc0f43 100644 --- a/gateway/ListeGateway.php +++ b/gateway/ListeGateway.php @@ -66,6 +66,45 @@ class ListeGateway $results=$this->con->getResults(); return $results; } + + + public function getPublicLists():array{ + $listes = []; + $taches = null; + try { + + $query = "SELECT * FROM Liste WHERE idCreator IS NULL"; + + $co->executeQuery($query, []); + + $results = $this->con->getResults(); + + foreach($results as $row){ + $idListe = $row['id']; + $queryTaches = "SELECT * FROM Tache WHERE idListe=:idListe"; + $this->con->executeQuery($queryTaches, array(':idListe' => array($idListe, PDO::PARAM_INT))); + $resultsTaches = $co->getResults(); + + foreach($resultsTaches as $rowTaches){ + if($rowTaches['complete']=="0"){ + $taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],false,$idListe); + }else{ + $taches[] = new Tache($rowTaches['id'], $rowTaches['nom'],true,$idListe); + } + + } + + $listes[] = new Liste($row['id'], $row['nom'],null, $taches); + $taches = null; + } + } + catch(PDOException $Exception) { + echo 'erreur'; + echo $Exception->getMessage(); + } + + return $listes; + } } ?> \ No newline at end of file diff --git a/gateway/UserGateway.php b/gateway/UserGateway.php index 27204c8..119bc20 100644 --- a/gateway/UserGateway.php +++ b/gateway/UserGateway.php @@ -9,11 +9,21 @@ class UserGateway $this->con = $con; } - public function insert(User $u): void{ - $query = "INSERT INTO Utilisateur VALUES (null, :username, :password)"; - $this->con->executeQuery($query, array(':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR))); + public function insert(User $u){ + try{ + $query = "INSERT INTO Utilisateur VALUES (null, :username, :password)"; + $this->con->executeQuery($query, array(':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR))); + } + catch(PDOException $Exception){ + echo 'erreur'; + echo $Exception->getMessage(); + return false; + } + return true; } + + public function delete(User $u): void{ $query = "DELETE FROM Utilisateur where id=:id"; $this->con->executeQuery($query, array(':id' => array($u->getId(), PDO::PARAM_INT))); @@ -24,13 +34,6 @@ class UserGateway $this->con->executeQuery($query, array(':id' => array($u->getId(), PDO::PARAM_INT), ':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR))); } - public function findByNamePassword(string $username, string $password): array{ - $query = "SELECT * FROM Utilisateur WHERE username=:username AND password=:password"; - $this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR), ':password' => array($password, PDO::PARAM_STR))); - $results=$this->con->getResults(); - return $results; - } - public function findByName(string $username): array{ $query = "SELECT * FROM Utilisateur WHERE username=:username"; $this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR))); @@ -45,20 +48,16 @@ class UserGateway return $results; } -/* - public function getTacheFromIdList(int $id): array{ - $tabTaches=[]; - $query = "SELECT * FROM Tache t where idListe=:id"; - $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); - $results=$this->con->getResults(); - foreach ($results as $row) { - $tabTaches[]=new Tache($row['id'], $row['name'], $row['content'], $row['completed']); + function getHashedPassword(string $usrname):?string{ + $truePasswd=null; + $query="SELECT password FROM Utilisateur WHERE name=:name"; + $this->con->executeQuery($query,array('name'=>array($usrname,PDO::PARAM_STR))); + $results=$co->getResults(); + foreach($res as $row){ + $results=$row['pwd']; } - return $tabTaches; + return $truePasswd; } - - -*/ } ?> \ No newline at end of file diff --git a/index.php b/index.php index 54cc888..47ed283 100644 --- a/index.php +++ b/index.php @@ -1,20 +1,14 @@ - - - - getMessage(); -} +// Construction du controleur +//$cont=new FrontControleur(); +$cont= new FrontController(); ?> - - - \ No newline at end of file diff --git a/modeles/MdlListe.php b/modeles/MdlListe.php index b0530ee..ed979d5 100644 --- a/modeles/MdlListe.php +++ b/modeles/MdlListe.php @@ -70,6 +70,11 @@ class MdlListe{ } return $tabListe; } + + public function getPublicList(){ + $gate=new ListeGateway($this->con); + return $gate->getPublicLists(); + } } diff --git a/modeles/MdlUser.php b/modeles/MdlUser.php index 3341823..41a162f 100644 --- a/modeles/MdlUser.php +++ b/modeles/MdlUser.php @@ -9,29 +9,17 @@ class MdlUser{ $this->con = $con; } - public function getUserForConnection(string $username, string $password): ?User{ - if (!empty($username) && !empty($password)){ - $gate=new UserGateway($this->con); - $results=$gate->findByNamePassword($username, $password); - if (!empty($results)){ - $user=new User($results[0]['id'], $results[0]['username'], $results[0]['password']); - return $user; - } - } - return null; + public function connexion($login){ + $_SESSION['role'] = 'Utilisateur'; + $_SESSION['login'] = $login; } - public function insert(string $username, string $password): ?User{ - $gate=new UserGateway($this->con); - $results=$gate->findByName($username); - if ($results==null){ - $u=new User(0, $username, $password); - $gate->insert($u); - $id=$gate->getLastId(); - $u->setId($id[0]['oldId']); - return $u; + public function signUp($login, $mdp){ + $result=$this->con->insert($login, $mdp); + if ($result==true){ + $_SESSION['role'] = 'Utilisateur'; + $_SESSION['login'] = $login; } - return null; } public function delete(User $user){ @@ -52,6 +40,18 @@ class MdlUser{ $_SESSION = array(); } + public function existUser(string $name):bool{ + $gate=new UserGateway($this->con); + if($gate->findByName($name) != null){ + return true; + } + return false; + } + + public function getPasswordHash(string $usr){ + return $con->getHashedPassword($usr); + } + }