mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 18:20:38 +00:00
- set social login credentials
- disallow registration refactoring
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Artisan;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Requests\StoreSocialServiceCredentialsRequest;
|
||||
|
||||
class StoreSocialServiceCredentialsController
|
||||
{
|
||||
/**
|
||||
* Configure stripe additionally
|
||||
*/
|
||||
public function __invoke(StoreSocialServiceCredentialsRequest $request): Response
|
||||
{
|
||||
// Abort in demo mode
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Set on social login
|
||||
Setting::updateOrCreate([
|
||||
'name' => "allowed_{$request->input('service')}_login",
|
||||
], [
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
// Get and store credentials
|
||||
if (! app()->runningUnitTests()) {
|
||||
$credentials = [
|
||||
'facebook' => [
|
||||
'FACEBOOK_CLIENT_ID' => $request->input('client_id'),
|
||||
'FACEBOOK_CLIENT_SECRET' => $request->input('client_secret'),
|
||||
],
|
||||
'google' => [
|
||||
'GOOGLE_CLIENT_ID' => $request->input('client_id'),
|
||||
'GOOGLE_CLIENT_SECRET' => $request->input('client_secret'),
|
||||
],
|
||||
'github' => [
|
||||
'GITHUB_CLIENT_ID' => $request->input('client_id'),
|
||||
'GITHUB_CLIENT_SECRET' => $request->input('client_secret'),
|
||||
],
|
||||
];
|
||||
|
||||
// Store credentials into the .env file
|
||||
setEnvironmentValue($credentials[$request->input('service')]);
|
||||
|
||||
// Clear cache
|
||||
if (! is_dev()) {
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreSocialServiceCredentialsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'client_id' => 'required|string',
|
||||
'client_secret' => 'required|string',
|
||||
'service' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user