Reputation: 9
Basically i want to assign different different APP_KEY to different different user i have stored generated app_key in "users table" so, my question is how can i achieve this? i have try but can't get proper solution
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => Auth::User()->APP_KEY
'cipher' => 'AES-256-CBC',
Upvotes: 0
Views: 154
Reputation: 472
you can create one middleware, and inside of handle method change config value...
class SetConfig
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
config()->set("app.key", Auth::User()->APP_KEY);
return $next($request);
}
}
and need to init middleware on App\Http\Kernel
like this:
protected $middleware = [
...
SetConfig::class,
...
];
or on provider :
$router = $this->app['router'];
$router->pushMiddlewareToGroup('web', SetConfig::class);
Upvotes: 1