My site loads different pages on different Operating Systems

Asked

Viewed 224 times

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: windows

on Ubuntu: linux

  • 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 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.

  • In Windows the session was saved in the browser, but not in Ubuntu.

  • @user5631 already cleared all cookie and browser session, apparently have nothing saved. I have tested in another browser too.

  • @user5631 session has to do with browser, not operating system

  • 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.

Show 1 more comment

1 answer

1

Guy by what it looks like in Ubuntu drops if guest from filter auth - try removing this check in filter auth and see what happens

  • thanks for the attempt, but it didn’t solve

  • Try to debug the code on both platforms - debug before redirect

  • I debugged all the way and could not find anything. I try to access the route '/' and it sends me to user/login. I have no idea what might be going on...

  • Dude, I can’t say this, can you put your code on github? then I clone it and test it on my Ubuntu

  • hello buddy, I committed it to test only http://github.com/tiaguinhow/buglinux

  • Blz, I’ll look there, try to also lift a linux vm and test its code

  • Thank you George, I’m testing the code all the time rsrs. What would a linux vm ? (I’m new to linux)

  • A vm is abbreviation of virtual machine - you can run several Sos in a cimputador msm - download the virtualbox and dps download one . Ubuntu iso, dps eh so create a virtual machine(vm) and connect, ai vc can use, for example windows and linux at msm time.

  • ah yes, virtual machine I know how it works. I can test here too, but I think it would be the same as using a real machine, would not be ?

  • 1

    Yes it would be, but it is good to test on more than one pc.

  • Dude, I’m not gonna be able to test your code now, just later

  • George, give me some feedback... brigade

  • everything went all right with git George ? Hugs

  • Man, did you solve the problem, man? I’m sorry about the weather...

  • ola @George, I haven’t been able to yet, but I’ve dropped by now. I’m on other projects. Thanks, [s]

  • Blz, I know how eh!!! Good luck in your projects ;)

Show 11 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.