Added redirects and middleware classes for login
This commit is contained in:
35
src/Application/Helper/Redirect.php
Normal file
35
src/Application/Helper/Redirect.php
Normal 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'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user