2
I’m going through a very strange problem.
When using Windows (Windows 7), my page loads as expected:
@extends + index.php
Already on Linux (Ubuntu 13.10) it is redirecting me to the route /user/login for no reason:
@extends + login.php
On both systems, the folder was copied from Dropbox without the vendor and later installed via Composer install
I thought that in the filter or in the routes there could be something conflicting, but it makes no sense in one system to load normally and in the other to call for an unexpected page.
Route:
<?php
/** ------------------------------------------
* Route model binding
* ------------------------------------------
*/
Route::model('user', 'User');
Route::model('comment', 'Comment');
Route::model('post', 'Post');
Route::model('role', 'Role');
Route::resource('upload', 'UploadController');
/** ------------------------------------------
* Admin Routes
* ------------------------------------------
*/
Route::group(['prefix' => 'admin', 'before' => 'auth'], function()
{
Route::pattern('user', '[0-9]+');
Route::pattern('role', '[0-9]+');
# User Management
Route::get('users/{user}/show', 'AdminUsersController@getShow');
Route::get('users/{user}/edit', 'AdminUsersController@getEdit');
Route::post('users/{user}/edit', 'AdminUsersController@postEdit');
Route::get('users/{user}/delete', 'AdminUsersController@getDelete');
Route::post('users/{user}/delete', 'AdminUsersController@postDelete');
Route::controller('users', 'AdminUsersController');
# User Role Management
Route::get('roles/{role}/show', 'AdminRolesController@getShow');
Route::get('roles/{role}/edit', 'AdminRolesController@getEdit');
Route::post('roles/{role}/edit', 'AdminRolesController@postEdit');
Route::get('roles/{role}/delete', 'AdminRolesController@getDelete');
Route::post('roles/{role}/delete', 'AdminRolesController@postDelete');
Route::controller('roles', 'AdminRolesController');
# Optional
Route::get('faq', 'AdminUsersController@getFaq');
Route::get('profile', 'AdminUsersController@getProfile');
Route::get('mural', 'AdminUsersController@getMural');
# Admin Dashboard
Route::controller('/', 'AdminDashboardController');
});
/** ------------------------------------------
* User Routes
* ------------------------------------------
*/
Route::group(['prefix' => 'user', 'before' => 'auth'], function()
{
// User reset routes
Route::get('reset/{token}', 'UserController@getReset')
->where('token', '[0-9a-z]+');
// User password reset
Route::post('reset/{token}', 'UserController@postReset')
->where('token', '[0-9a-z]+');
//:: User Account Routes ::
Route::post('{user}/edit', 'UserController@postEdit')
->where('user', '[0-9]+');
# Admin Dashboard
Route::controller('/', 'UserDashboardController');
});
/** ------------------------------------------
* Frontend Routes
* ------------------------------------------
*/
//:: User Account Routes ::
Route::post('user/login', 'UserController@postLogin');
# User RESTful Routes (Login, Logout, Register, etc)
Route::controller('user', 'UserController');
# Index Page - Last route, no matches
Route::get('/', ['before' => 'detectLang','uses' => 'UserController@getIndex']);
Route::post('/', ['before' => 'detectLang','uses' => 'UserController@postIndex']);
Filter:
<?php
App::before(function($request)
{
//
});
App::after(function($request, $response)
{
//
});
Route::filter('auth', function()
{
if (Auth::guest()) {
Session::put('loginRedirect', Request::url());
return Redirect::to('/');
}
});
Route::filter('auth.basic', function()
{
return Auth::basic();
});
Route::filter('guest', function()
{
if (Auth::check()) return Redirect::to('/');
});
// Check for role on all admin routes
Entrust::routeNeedsRole( 'admin*', array('admin'), Redirect::to('/') );
// Check for permissions on admin actions
Entrust::routeNeedsPermission( 'admin/blogs*', 'full', Redirect::to('/admin') );
Entrust::routeNeedsPermission( 'admin/comments*', 'full', Redirect::to('/admin') );
Entrust::routeNeedsPermission( 'admin/users*', 'full', Redirect::to('/admin') );
Entrust::routeNeedsPermission( 'admin/roles*', 'full', Redirect::to('/admin') );
Route::filter('csrf', function()
{
if (Request::ajax()){
if (Session::getToken() != Request::header('X-CSRF-Token')){
throw new Illuminate\Session\TokenMismatchException;
}
}else if (Session::getToken() != Input::get('csrf_token') && Session::getToken() != Input::get('_token')){
throw new Illuminate\Session\TokenMismatchException;
}
});
Route::filter('detectLang', function($route, $request, $lang = 'auto')
{
if($lang != "auto" && in_array($lang , Config::get('app.available_language')))
{
Config::set('app.locale', $lang);
}else{
$browser_lang = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : '';
$browser_lang = substr($browser_lang, 0,2);
$userLang = (in_array($browser_lang, Config::get('app.available_language'))) ? $browser_lang : Config::get('app.locale');
Config::set('app.locale', $userLang);
App::setLocale($userLang);
}
});
Index:
@extends('layouts.default')
@section('header')
@parent
@stop
on Windows:
on Ubuntu:
Everything indicates that you are "logged in" to Windows, but you are not "logged in" to Ubuntu - and therefore is redirected to the login page.
– J. Bruni
@J.Bruni but this has direct connection with Laravel ? in case how would you 'log in' in Ubuntu ? if Voce refers to logging into the site, both are not authenticated, and my so-called index.php page does not require authentication.
– tiaguinhow
In Windows the session was saved in the browser, but not in Ubuntu.
– user5631
@user5631 already cleared all cookie and browser session, apparently have nothing saved. I have tested in another browser too.
– tiaguinhow
@user5631 session has to do with browser, not operating system
– Silvio Andorinha
Did you check upper and lower case on all paths? On Windows it doesn’t change anything, but on other "Oses" it makes a difference.
– Bacco