Password verification
This commit is contained in:
		@@ -24,11 +24,23 @@ class Login {
 | 
			
		||||
        });
 | 
			
		||||
		$app->post('/login', function ($request, $response, $args) {
 | 
			
		||||
            // Render index view
 | 
			
		||||
			$post = $request->getParsedBody();
 | 
			
		||||
			
 | 
			
		||||
			if(isset($_POST["username"])){
 | 
			
		||||
				echo "Jouw naam is: " . $_POST["username"] . " en je wachtwoord is: " . $_POST["password"] . "<br/>\n";
 | 
			
		||||
			$user = $this->db->gebruikers("username = ?", $post["username"]);
 | 
			
		||||
			if ($user->count("*") === 0){
 | 
			
		||||
				echo "Onjuiste gebruikersnaam of wachtwoord";
 | 
			
		||||
			} else {
 | 
			
		||||
				if(password_verify($post["password"], $user["password"])){
 | 
			
		||||
					session_start();
 | 
			
		||||
					$_SESSION["user"] = [
 | 
			
		||||
						"uuid" => $user["uuid"],
 | 
			
		||||
						"username" => $user["username"]
 | 
			
		||||
					];
 | 
			
		||||
				}else{
 | 
			
		||||
					echo "fout";
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			$newResponse = $response->withHeader('Location', 'index.php');
 | 
			
		||||
			$newResponse = $response->withHeader('Location', '');
 | 
			
		||||
			return $this->renderer->render($newResponse, 'login.phtml', $args);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user