Skip to content

Commit

Permalink
Normalize for case-sensitive server environments
Browse files Browse the repository at this point in the history
normalize route/controller/action after parsing uri to work as expected in case-sensitive server environments.
  • Loading branch information
sherifabdlnaby committed Mar 1, 2018
1 parent 25f548b commit 6020e9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Controllers/Web/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

class AccountController extends WebController {

public function index(){
public function Index(){
return $this->renderFullError('Not Found', 404);
}

public function login(){
public function Login(){
if($_SERVER['REQUEST_METHOD'] == 'POST') {
//LOGIN
if(LoginService::login($_POST['username'], $_POST['password']))
Expand All @@ -37,7 +37,7 @@ public function login(){
}
}

public function register(){
public function Register(){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (RegisterService::Register($_POST['name'], $_POST['username'], $_POST['password'], $_POST['confirmPassword'], $_POST['email']))
return $this->redirect('/');
Expand All @@ -49,14 +49,14 @@ public function register(){
return $this->render();
}

public function logout(){
public function Logout(){
Session::destroyLoginSession();
if(!empty($_GET['returnUrl']))
return $this->redirect($_GET['returnUrl']);
return $this->redirect('/');
}

public function view($username){
public function View($username){

$userRepository = new UserRepository();

Expand Down
5 changes: 5 additions & 0 deletions Core/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public function __construct(&$uri)
//Get Params
$this->params = $path_parts;
}

//normalize route/controller/action to the expected case
$this->route = ucfirst(strtolower($this->route));
$this->controller = ucfirst(strtolower($this->controller));
$this->action = ucfirst(strtolower($this->action));
}

/**
Expand Down

0 comments on commit 6020e9f

Please sign in to comment.