-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
518b781
commit 1a8a1a6
Showing
6 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Controllers; | ||
|
||
|
||
class User extends Controller | ||
{ | ||
|
||
protected $modelName = \Model\User::class; | ||
|
||
|
||
public function login(){ | ||
$reponse = null; | ||
|
||
if(!empty($_POST['username']) && !empty($_POST['password'])){ | ||
$usernameLogin = $_POST['username']; | ||
$passwordLogin = $_POST['password']; | ||
$resultLogin = $this->model->login($usernameLogin, $passwordLogin); | ||
if($resultLogin){ | ||
\Http::redirect('index.php?controller=gateau&task=index'); | ||
}else{ | ||
$reponse = "Erreur de connexion"; | ||
} | ||
} | ||
$titreDeLaPage = "Connection"; | ||
\Rendering::render('users/login', compact('reponse', 'titreDeLaPage')); | ||
} | ||
|
||
public function loggout(){ | ||
$this->model->loggout(); | ||
|
||
\Http::redirect('index.php?controller=gateau&task=index'); | ||
} | ||
|
||
|
||
public function index(){ | ||
$LoggedIn = $this->model->isLoggedIn(); | ||
if($LoggedIn){ | ||
$titreDeLaPage = "Profil"; | ||
\Rendering::render('users/profil', compact('titreDeLaPage')); | ||
}else{ | ||
\Http::redirect('index.php?controller=gateau&task=index'); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
|
||
session_start(); | ||
//on récupère les librairies nécéssaires | ||
|
||
require_once "core/autoloading.php"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<h3>Connecte toi !</h3> | ||
<h4><?php echo $reponse; ?></h4> | ||
<form method="POST" action="index.php?controller=user&task=login"> | ||
<div class="form-group"> | ||
<label for="username">Username</label> | ||
<input type="text" class="form-control" name="username" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password">password</label> | ||
<input type="password" class="form-control" name="password" required> | ||
</div> | ||
<div class="form-group"> | ||
<input type="submit" value="Log in" class="btn btn-outline-light"> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php $user = $_SESSION['user'];?> | ||
<h1><?php echo $user['userName']; ?></h1> | ||
<h5><?php echo $user['userEmail']; ?></h5> | ||
|
||
|