KoolReport's Forum

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

Login to Dashboard from other App #3291

Closed John opened this topic on on May 17 - 2 comments

John commented on May 17

I use a Web App and i want my users to be able to use Koolreport Dashboards without having to login to it again. I know that i could authenticate users based on my database users table but i also want to automate the login function. So i'm thinking of using webhook for this. I could send one from my Web App to Kool Dashboard but i don't know if there is any endpoint to receive this webhook call. Could you give me some advice on this?

KoolReport commented on May 18

As you know the Dashboard app can set User directly. So in the index.php you can do something like this:

<?php

require_once "vendor/autoload.php";
require_once "/path/to/App.php";

use \koolreport\dashboard\User;

$app = App::create();

// Now, you make any request to your web app to get user identity

$userInfo = getUserInfoFromYourWebApp();

// If you retrieve correct $userInfo then you create User identity for Dashboard

if($userInfo)
{
    $user = User::create()
                ->id($userInfo["id"])
                ->name($userInfo["name"])
                ->avatar($userInfo["avatar"])
                ->roles($userInfo["role"]);
    //The id and name are the most important info, others are optional.

    $app->user($user); //Set the user to app.
}


// Lastly, you run the app as normal

$app->run();

So the logic is, if you found the user has login in your web app, then you set the dashboard with that user info, the dashboard will bypass the login authentication. If userInfo is null, meaning user has not login, the login authentication page will be shown in dashboard for user to login.

Here is reference from our documentation: https://www.koolreport.com/docs/dashboard/application/#authentication-set-user-directly

Hope that helps.

John commented on Jun 1

Thanks!

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

Dashboard