I want to use access keys for responsivefilemanager. Since access keys can be seen by the users(example.com/filemanager/dialog.php?akey=usersaccesskeys), I want the access keys to be temporary(single use only). But I think I need "auth()" and other functions like "User::find($user_id)" to do this. Anyways there is an error when I use auth() or controller functions in config file of the filemanager, "Call to undefined function auth() in /path/to/config/config.php". I am stuck and I don't want to deploy my website like this. Is there any other ways to make responsivefilemanager secure?
I have also tried using controller php file in app\Http\Controllers\RfmController.php Other error shows "Uncaught Error: Class 'App\Http\Controllers\Controller'" This is the function RfmController extends to.
I am running LAMP server. PHP 7.3.7 Laravel 5.8
In my config.php
'access_keys' => array(auth()->user()->name),
by using controller.php
In my config.php
namespace App\Http\Controllers;
require('/path/to/app/Http/Controllers/RfmController.php');
$rfm = new RfmController;
.
.
.
'access_keys' => array(RFMClass::rfmakey()),
In RfmController.php
namespace App\Http\Controllers;
class RfmController extends Controller
{
public function rfmakey()
{
return auth()->user()->id;
}
{
I expected that rfmakey() would return the username
You need to use middleware. From the official laravel documentation:
If you are using controllers, you may call the middleware method from the controller's constructor instead of attaching it in the route definition directly:
As an aside, I would stay away from putting dynamic values or code in my config.php file, like
This is not a good practice.
Hope this solution helps you!