KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Dashboard: Use accountMenu without login #2394

Closed Andre Van Der Walt opened this topic on on Oct 15, 2021 - 4 comments

Andre Van Der Walt commented on Oct 15, 2021

Hi,

Please provide an example of how to use accountMenu without the login page. Can we have more details about this: https://www.koolreport.com/docs/dashboard/application/#authentication-set-user-directly.

Do we still have to return Login class like this?


protected function login()
    {
        return  Login::create()
                ->authenticate(function($username,$password){
                    if($username==="admin@example.com" && $password==="admin_password")
                    {
                        // If authenticated, return User object
                        return User::create()
                            ->id(1)
                            ->name("Admin")
                            ->avatar("avatars/8.jpg")
                            ->roles(["admin"]);
                    }
                    // If unauthenticated, return null
                    return null;
                });
    }


KoolReport commented on Oct 15, 2021

If you do want login, then remove the whole login() method. Still, accountMenu need user to be shown so you insert fake user directly by:

App::create()->user(
    User::create()
    ->id(1)
    ->name("User")
)

You can change the accountMenu by providing list of MenuItem into accountMenu() method

protected function accountMenu()
{
    return [
        MenuItem::create()->...
    ];
}

Please refer to our App account menu documentation for more information.

Andre Van Der Walt commented on Oct 15, 2021

Where do you insert fake user? Tried different options in index.php etc. but the account menu still do not show.

App::create()->user(
    User::create()
    ->id(1)
    ->name("User")
)

KoolReport commented on Oct 15, 2021

in the index.php where the App is created

Andre Van Der Walt commented on Oct 15, 2021

Sorted thank you!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

Dashboard