mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
fix email setup
This commit is contained in:
@@ -5,7 +5,10 @@ namespace App\Http\Controllers;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Setting;
|
||||
use Artisan;
|
||||
use Stripe;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
@@ -77,42 +80,74 @@ class SettingController extends Controller
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Get options
|
||||
$mail = collect([
|
||||
[
|
||||
'name' => 'MAIL_DRIVER',
|
||||
'value' => $request->input('driver'),
|
||||
],
|
||||
[
|
||||
'name' => 'MAIL_HOST',
|
||||
'value' => $request->input('host'),
|
||||
],
|
||||
[
|
||||
'name' => 'MAIL_PORT',
|
||||
'value' => $request->input('port'),
|
||||
],
|
||||
[
|
||||
'name' => 'MAIL_USERNAME',
|
||||
'value' => $request->input('username'),
|
||||
],
|
||||
[
|
||||
'name' => 'MAIL_PASSWORD',
|
||||
'value' => $request->input('password'),
|
||||
],
|
||||
[
|
||||
'name' => 'MAIL_ENCRYPTION',
|
||||
'value' => $request->input('encryption'),
|
||||
],
|
||||
setEnvironmentValue([
|
||||
'MAIL_DRIVER' => $request->input('driver'),
|
||||
'MAIL_HOST' => $request->input('host'),
|
||||
'MAIL_PORT' => $request->input('port'),
|
||||
'MAIL_USERNAME' => $request->input('username'),
|
||||
'MAIL_PASSWORD' => $request->input('password'),
|
||||
'MAIL_ENCRYPTION' => $request->input('encryption'),
|
||||
]);
|
||||
|
||||
// Store mail options
|
||||
$mail->each(function ($col) {
|
||||
setEnvironmentValue($col['name'], $col['value']);
|
||||
});
|
||||
|
||||
// Clear config cache
|
||||
Artisan::call('config:clear');
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure stripe additionally
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function set_stripe(Request $request)
|
||||
{
|
||||
// Get stripe status
|
||||
$is_stripe = get_setting('payments_configured');
|
||||
|
||||
// Check setup status
|
||||
if ($is_stripe) abort(401, 'Gone');
|
||||
|
||||
// Create stripe instance
|
||||
$stripe = Stripe::make($request->secret, '2020-03-02');
|
||||
|
||||
// Try to get stripe account details
|
||||
try {
|
||||
$stripe->account()->details();
|
||||
} catch (UnauthorizedException $e) {
|
||||
throw new HttpException(401, $e->getMessage());
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
});
|
||||
|
||||
// Set stripe credentials to .env
|
||||
setEnvironmentValue([
|
||||
'CASHIER_CURRENCY' => $request->currency,
|
||||
'STRIPE_KEY' => $request->key,
|
||||
'STRIPE_SECRET' => $request->secret,
|
||||
'STRIPE_WEBHOOK_SECRET' => $request->webhookSecret,
|
||||
]);
|
||||
|
||||
// Clear cache
|
||||
Artisan::call('config:cache');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"/js/main.js": "/js/main.js",
|
||||
"/css/app.css": "/css/app.css",
|
||||
"/js/main.856279ed3bfe1397fae7.hot-update.js": "/js/main.856279ed3bfe1397fae7.hot-update.js",
|
||||
"/js/main.9cab67db450838c320d4.hot-update.js": "/js/main.9cab67db450838c320d4.hot-update.js"
|
||||
"/js/main.b8036b7a9b7c277bad46.hot-update.js": "/js/main.b8036b7a9b7c277bad46.hot-update.js",
|
||||
"/js/main.83350fd29c57dbfa9818.hot-update.js": "/js/main.83350fd29c57dbfa9818.hot-update.js"
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@
|
||||
|
||||
// Send request to get verify account
|
||||
axios
|
||||
.post('/api/setup/stripe-credentials', this.stripeCredentials)
|
||||
.put('/api/settings/stripe', this.stripeCredentials)
|
||||
.then(() => {
|
||||
|
||||
// End loading
|
||||
|
||||
@@ -164,6 +164,7 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:m
|
||||
|
||||
// Settings
|
||||
Route::put('/settings/email', 'SettingController@set_email');
|
||||
Route::put('/settings/stripe', 'SettingController@set_stripe');
|
||||
Route::patch('/settings', 'SettingController@update');
|
||||
Route::get('/settings', 'SettingController@show');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user