Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logged in user can not track. #405

Open
bhargav960143 opened this issue Oct 20, 2018 · 8 comments
Open

Logged in user can not track. #405

bhargav960143 opened this issue Oct 20, 2018 · 8 comments
Assignees

Comments

@bhargav960143
Copy link

My app db and tracker db are different.

Config/tracker.php file

'user_model' =>  'App\User',

Please guide me how can i get user?

Check my kernel.php still user entry is null in tracker session table

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
        \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}

@bhargav960143 bhargav960143 changed the title Logged in user can not logged. Logged in user can not track. Oct 20, 2018
@Haftisha
Copy link

Same goes here

@Haftisha
Copy link

Haftisha commented Oct 26, 2018

Solved. You should put the tracker's middleware under $middlewareGroups within web. And change the tracker's session model relationship (vendor\pragmarx\src\Vendor\Laravel\Models\Session.php Line 31) as follows unless you are using the default Laravel users table
public function user() { return $this->belongsTo($this->getConfig()->get('user_model'), 'user_id', $this->getConfig()->get('authenticated_user_id_column')); }

@lipasite
Copy link

You should put the tracker's middleware under $middlewareGroups within web.

How? Show the example plaese...
I have same issue

@Haftisha
Copy link

Haftisha commented Nov 29, 2018

@lipasite

protected $middlewareGroups = [
        'web' =>
        [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

@napestershine
Copy link
Collaborator

@bhargav960143
@lipasite
@Haftisha

Is this solved ?

@napestershine napestershine self-assigned this Jan 27, 2019
@bhargav960143
Copy link
Author

Nop

@bhargav960143
Copy link
Author

Nop

@napestershine can you please guide me how can i resolve this issue?

@danaki
Copy link

danaki commented Mar 6, 2019

Any updates on this? Module tracks visits, but user_id column is always NULL. \Auth doesn't provide method check() but Guard does. Does moving to $middlewareGroups->'web' help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants