1
0

Added redirects and middleware classes for login

This commit is contained in:
2017-03-26 16:07:10 +02:00
parent 40d3ec9052
commit 014adeed65
7 changed files with 88 additions and 35 deletions

View File

@ -0,0 +1,35 @@
<?php
/**
* Informatica Eindproject D4p
* 6in3, Stedelijk Gymnasium Nijmegen
* Docent: Hans de Wolf
*
* ==================
*
* Daniel Boutros,
* Christiaan Goossens,
* Jelmer Hinssen
*/
namespace Inforbank\Application\Helper;
class Redirect
{
public static function create($response, $path)
{
$response = $response->withStatus(302);
$response = $response->withHeader('Location', Redirect::getBasepath() . $path);
return $response;
}
private static function getBasepath()
{
if (isset($_SERVER['HTTPS'])) {
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
} else {
$protocol = 'http';
}
return $protocol . "://" . $_SERVER['HTTP_HOST'];
}
}