mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-27 06:54:41 +00:00
Test mailgun connection before storing credentials into the app
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
## Version 2.0.16
|
||||||
|
#### Release date: 8. April 2022
|
||||||
|
- Test mailgun connection before storing your credentials into the app
|
||||||
|
- UI enhancements & fixes
|
||||||
|
|
||||||
## Version 2.0.15
|
## Version 2.0.15
|
||||||
#### Release date: 6. April 2022
|
#### Release date: 6. April 2022
|
||||||
- Wasabi region list updated
|
- Wasabi region list updated
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ return [
|
|||||||
'clear_cache' => 'Clear Cache',
|
'clear_cache' => 'Clear Cache',
|
||||||
'admin_settings.others.contact_email' => 'Contact Email',
|
'admin_settings.others.contact_email' => 'Contact Email',
|
||||||
'admin_settings.others.contact_email_plac' => 'Type your contact email',
|
'admin_settings.others.contact_email_plac' => 'Type your contact email',
|
||||||
'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in MB)',
|
'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)',
|
||||||
'admin_settings.others.default_storage_plac' => 'Set default storage space in GB',
|
'admin_settings.others.default_storage_plac' => 'Set default storage space in GB',
|
||||||
'admin_settings.others.google_analytics' => 'Google Analytics Code (optional)',
|
'admin_settings.others.google_analytics' => 'Google Analytics Code (optional)',
|
||||||
'admin_settings.others.google_analytics_plac' => 'Paste your Google Analytics Code',
|
'admin_settings.others.google_analytics_plac' => 'Paste your Google Analytics Code',
|
||||||
@@ -551,8 +551,8 @@ return [
|
|||||||
'routes_title.users_user' => 'User',
|
'routes_title.users_user' => 'User',
|
||||||
'can_download_file' => 'Can download file',
|
'can_download_file' => 'Can download file',
|
||||||
'shared.editor' => 'Can edit and upload files',
|
'shared.editor' => 'Can edit and upload files',
|
||||||
'shared.empty_shared' => "Nothing Shared Yet",
|
'shared.empty_shared' => 'Nothing Shared Yet',
|
||||||
'shared.empty_shared_desc' => "All items you share will be visible here.",
|
'shared.empty_shared_desc' => 'All items you share will be visible here.',
|
||||||
'shared.visitor' => 'Can only view and download',
|
'shared.visitor' => 'Can only view and download',
|
||||||
'awesome_iam_done' => 'Awesome, I’m done!',
|
'awesome_iam_done' => 'Awesome, I’m done!',
|
||||||
'generate_link' => 'Generate Link',
|
'generate_link' => 'Generate Link',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"/chunks/status-check.js": "/chunks/status-check.js?id=f82f9939c1326fe2",
|
"/chunks/status-check.js": "/chunks/status-check.js?id=f82f9939c1326fe2",
|
||||||
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=df5bd89528649783",
|
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=df5bd89528649783",
|
||||||
"/chunks/database.js": "/chunks/database.js?id=15cc488117dccf7b",
|
"/chunks/database.js": "/chunks/database.js?id=15cc488117dccf7b",
|
||||||
"/chunks/environment.js": "/chunks/environment.js?id=166cd302ba7338ae",
|
"/chunks/environment.js": "/chunks/environment.js?id=dfc24aa910b0c667",
|
||||||
"/chunks/app-setup.js": "/chunks/app-setup.js?id=15938ff1ad2d6ed2",
|
"/chunks/app-setup.js": "/chunks/app-setup.js?id=15938ff1ad2d6ed2",
|
||||||
"/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8",
|
"/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8",
|
||||||
"/chunks/shared.js": "/chunks/shared.js?id=ec06bf0d3ada0f65",
|
"/chunks/shared.js": "/chunks/shared.js?id=ec06bf0d3ada0f65",
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"/chunks/app-settings.js": "/chunks/app-settings.js?id=55da23af2b076069",
|
"/chunks/app-settings.js": "/chunks/app-settings.js?id=55da23af2b076069",
|
||||||
"/chunks/app-appearance.js": "/chunks/app-appearance.js?id=a694a01f3641712c",
|
"/chunks/app-appearance.js": "/chunks/app-appearance.js?id=a694a01f3641712c",
|
||||||
"/chunks/app-index.js": "/chunks/app-index.js?id=efdbfa062749ca00",
|
"/chunks/app-index.js": "/chunks/app-index.js?id=efdbfa062749ca00",
|
||||||
"/chunks/app-environment.js": "/chunks/app-environment.js?id=6e5e264c7417af60",
|
"/chunks/app-environment.js": "/chunks/app-environment.js?id=85670492c4e9fe78",
|
||||||
"/chunks/app-others.js": "/chunks/app-others.js?id=abb8d96cd7c3a576",
|
"/chunks/app-others.js": "/chunks/app-others.js?id=abb8d96cd7c3a576",
|
||||||
"/chunks/app-sign-in-out.js": "/chunks/app-sign-in-out.js?id=1cfffc99465b9a7a",
|
"/chunks/app-sign-in-out.js": "/chunks/app-sign-in-out.js?id=1cfffc99465b9a7a",
|
||||||
"/chunks/app-adsense.js": "/chunks/app-adsense.js?id=a5dc9e715f8561bd",
|
"/chunks/app-adsense.js": "/chunks/app-adsense.js?id=a5dc9e715f8561bd",
|
||||||
|
|||||||
Vendored
+1
-1
@@ -31,7 +31,7 @@ const defaultState = {
|
|||||||
value: 'postmark',
|
value: 'postmark',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Log',
|
label: 'None (Log)',
|
||||||
value: 'log',
|
value: 'log',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -374,13 +374,12 @@
|
|||||||
|
|
||||||
<ValidationProvider tag="div" mode="passive" name="Endpoint" rules="required" v-slot="{ errors }">
|
<ValidationProvider tag="div" mode="passive" name="Endpoint" rules="required" v-slot="{ errors }">
|
||||||
<AppInputText title="Endpoint" :error="errors[0]">
|
<AppInputText title="Endpoint" :error="errors[0]">
|
||||||
<input
|
<SelectInput
|
||||||
class="focus-border-theme input-dark"
|
v-model="mailgun.endpoint"
|
||||||
v-model="mailgun.endpoint"
|
:options="mailgunRegions"
|
||||||
placeholder="Type your endpoint"
|
placeholder="Select your endpoint"
|
||||||
type="text"
|
:isError="errors[0]"
|
||||||
:class="{ '!border-rose-600': errors[0] }"
|
/>
|
||||||
/>
|
|
||||||
</AppInputText>
|
</AppInputText>
|
||||||
</ValidationProvider>
|
</ValidationProvider>
|
||||||
</div>
|
</div>
|
||||||
@@ -563,6 +562,16 @@ export default {
|
|||||||
value: 'none',
|
value: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
mailgunRegions: [
|
||||||
|
{
|
||||||
|
label: 'US Endpoint (api.mailgun.net)',
|
||||||
|
value: 'api.mailgun.net',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'EU Endpoint (api.eu.mailgun.net)',
|
||||||
|
value: 'api.eu.mailgun.net',
|
||||||
|
},
|
||||||
|
],
|
||||||
pusherClusters: [
|
pusherClusters: [
|
||||||
{
|
{
|
||||||
label: 'US East (N. Virginia)',
|
label: 'US East (N. Virginia)',
|
||||||
|
|||||||
@@ -306,13 +306,12 @@
|
|||||||
v-slot="{ errors }"
|
v-slot="{ errors }"
|
||||||
>
|
>
|
||||||
<AppInputText title="Endpoint" :error="errors[0]" :is-last="true">
|
<AppInputText title="Endpoint" :error="errors[0]" :is-last="true">
|
||||||
<input
|
<SelectInput
|
||||||
class="focus-border-theme input-dark"
|
v-model="mailgun.endpoint"
|
||||||
v-model="mailgun.endpoint"
|
:options="mailgunRegions"
|
||||||
placeholder="Type your endpoint"
|
placeholder="Select your endpoint"
|
||||||
type="text"
|
:isError="errors[0]"
|
||||||
:class="{ '!border-rose-600': errors[0] }"
|
/>
|
||||||
/>
|
|
||||||
</AppInputText>
|
</AppInputText>
|
||||||
</ValidationProvider>
|
</ValidationProvider>
|
||||||
</div>
|
</div>
|
||||||
@@ -939,6 +938,16 @@ export default {
|
|||||||
value: 'none',
|
value: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
mailgunRegions: [
|
||||||
|
{
|
||||||
|
label: 'US Endpoint (api.mailgun.net)',
|
||||||
|
value: 'api.mailgun.net',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'EU Endpoint (api.eu.mailgun.net)',
|
||||||
|
value: 'api.eu.mailgun.net',
|
||||||
|
},
|
||||||
|
],
|
||||||
pusherClusters: [
|
pusherClusters: [
|
||||||
{
|
{
|
||||||
label: 'US East (N. Virginia)',
|
label: 'US East (N. Virginia)',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use Illuminate\Console\Scheduling\Schedule;
|
|||||||
use App\Console\Commands\SetupDevEnvironment;
|
use App\Console\Commands\SetupDevEnvironment;
|
||||||
use App\Console\Commands\SetupProdEnvironment;
|
use App\Console\Commands\SetupProdEnvironment;
|
||||||
use Support\Scheduler\Actions\ReportUsageAction;
|
use Support\Scheduler\Actions\ReportUsageAction;
|
||||||
|
use Support\Upgrading\Actions\UpdateSystemAction;
|
||||||
use Support\Demo\Actions\ClearHowdyDemoDataAction;
|
use Support\Demo\Actions\ClearHowdyDemoDataAction;
|
||||||
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
@@ -12,7 +13,6 @@ use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
|||||||
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
||||||
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
|
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
|
||||||
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
||||||
use Support\Upgrading\Actions\UpdateSystemAction;
|
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
namespace Domain\Settings\Actions;
|
||||||
|
|
||||||
|
use Mail;
|
||||||
|
use Domain\Settings\Mail\TestMail;
|
||||||
|
use Symfony\Component\Mailer\Exception\LogicException;
|
||||||
|
use Symfony\Component\Mailer\Exception\TransportException;
|
||||||
|
|
||||||
|
class TestMailgunConnectionAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Throw an Exception if connection isn't successful.
|
||||||
|
*
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
|
public function __invoke(array $credentials)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Set temporary mail connection
|
||||||
|
config([
|
||||||
|
'mail' => [
|
||||||
|
'driver' => 'mailgun',
|
||||||
|
],
|
||||||
|
'services' => [
|
||||||
|
'mailgun' => [
|
||||||
|
'domain' => $credentials['domain'],
|
||||||
|
'secret' => $credentials['secret'],
|
||||||
|
'endpoint' => $credentials['endpoint'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Send test email
|
||||||
|
Mail::to('test@hi5ve.digital')->send(new TestMail('example@domain.com'));
|
||||||
|
} catch (TransportException | LogicException $error) {
|
||||||
|
abort(
|
||||||
|
response()->json([
|
||||||
|
'type' => 'mailer-connection-error',
|
||||||
|
'title' => 'Mail Connection Error',
|
||||||
|
'message' => $error->getMessage(),
|
||||||
|
], 401)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,31 +2,43 @@
|
|||||||
namespace Domain\Settings\Actions;
|
namespace Domain\Settings\Actions;
|
||||||
|
|
||||||
use Storage;
|
use Storage;
|
||||||
|
use Aws\S3\Exception\S3Exception;
|
||||||
|
use League\Flysystem\UnableToWriteFile;
|
||||||
use Domain\Settings\DTO\S3CredentialsData;
|
use Domain\Settings\DTO\S3CredentialsData;
|
||||||
|
|
||||||
class TestS3ConnectionAction
|
class TestS3ConnectionAction
|
||||||
{
|
{
|
||||||
public function __invoke(S3CredentialsData $credentials): void
|
public function __invoke(S3CredentialsData $credentials): void
|
||||||
{
|
{
|
||||||
// Set temporary s3 connection
|
try {
|
||||||
config([
|
// Set temporary s3 connection
|
||||||
'filesystems.disks.s3' => [
|
config([
|
||||||
'driver' => 's3',
|
'filesystems.disks.s3' => [
|
||||||
'key' => $credentials->key,
|
'driver' => 's3',
|
||||||
'secret' => $credentials->secret,
|
'key' => $credentials->key,
|
||||||
'region' => $credentials->region,
|
'secret' => $credentials->secret,
|
||||||
'bucket' => $credentials->bucket,
|
'region' => $credentials->region,
|
||||||
'endpoint' => $credentials->endpoint,
|
'bucket' => $credentials->bucket,
|
||||||
],
|
'endpoint' => $credentials->endpoint,
|
||||||
]);
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
// Try to get files
|
// Try to get files
|
||||||
Storage::disk('s3')->allFiles();
|
Storage::disk('s3')->allFiles();
|
||||||
|
|
||||||
// Try to create folder
|
// Try to create folder
|
||||||
Storage::disk('s3')->makeDirectory('s3-test');
|
Storage::disk('s3')->makeDirectory('s3-test');
|
||||||
|
|
||||||
// Delete test folder
|
// Delete test folder
|
||||||
Storage::disk('s3')->deleteDirectory('s3-test');
|
Storage::disk('s3')->deleteDirectory('s3-test');
|
||||||
|
} catch (S3Exception | UnableToWriteFile $error) {
|
||||||
|
abort(
|
||||||
|
response()->json([
|
||||||
|
'type' => 's3-connection-error',
|
||||||
|
'title' => 'S3 Connection Error',
|
||||||
|
'message' => $error->getMessage(),
|
||||||
|
], 401)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
namespace Domain\Settings\Actions;
|
||||||
|
|
||||||
|
use Mail;
|
||||||
|
use Domain\Settings\Mail\TestMail;
|
||||||
|
use Symfony\Component\Mailer\Exception\LogicException;
|
||||||
|
use Symfony\Component\Mailer\Exception\TransportException;
|
||||||
|
|
||||||
|
class TestSMTPConnectionAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Throw an Exception if connection isn't successful.
|
||||||
|
*
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
|
public function __invoke(array $credentials)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Set temporary mail connection
|
||||||
|
config(['mail' => [
|
||||||
|
'driver' => 'smtp',
|
||||||
|
'host' => $credentials['host'],
|
||||||
|
'port' => $credentials['port'],
|
||||||
|
'username' => $credentials['username'],
|
||||||
|
'password' => $credentials['password'],
|
||||||
|
'encryption' => $credentials['encryption'] ?? '',
|
||||||
|
'from' => [
|
||||||
|
'address' => $credentials['email'] ?? $credentials['username'],
|
||||||
|
'name' => $credentials['email'] ?? $credentials['username'],
|
||||||
|
],
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$sender = $credentials['email'] ?? $credentials['username'];
|
||||||
|
|
||||||
|
// Send test email
|
||||||
|
Mail::to('test@hi5ve.digital')->send(new TestMail($sender));
|
||||||
|
} catch (TransportException | LogicException $error) {
|
||||||
|
abort(
|
||||||
|
response()->json([
|
||||||
|
'type' => 'mailer-connection-error',
|
||||||
|
'title' => 'Mail Connection Error',
|
||||||
|
'message' => $error->getMessage(),
|
||||||
|
], 401)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Settings\Controllers;
|
namespace Domain\Settings\Controllers;
|
||||||
|
|
||||||
use Mail;
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Domain\Settings\Mail\TestMail;
|
use Domain\Settings\Actions\TestSMTPConnectionAction;
|
||||||
use Symfony\Component\Mailer\Exception\LogicException;
|
use Domain\Settings\Actions\TestMailgunConnectionAction;
|
||||||
use Domain\Settings\Requests\StoreEmailCredentialsRequest;
|
use Domain\Settings\Requests\StoreEmailCredentialsRequest;
|
||||||
use Symfony\Component\Mailer\Exception\TransportException;
|
|
||||||
|
|
||||||
class StoreEmailCredentialsController
|
class StoreEmailCredentialsController
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
private TestMailgunConnectionAction $testMailgunConnection,
|
||||||
|
private TestSMTPConnectionAction $testSMTPConnection,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set new email credentials to .env file
|
* Set new email credentials to .env file
|
||||||
*/
|
*/
|
||||||
public function __invoke(StoreEmailCredentialsRequest $request): Response
|
public function __invoke(StoreEmailCredentialsRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
// Abort in demo mode
|
// Abort in demo mode
|
||||||
abort_if(is_demo(), 204, 'Done.');
|
abort_if(is_demo(), 204, 'Done.');
|
||||||
|
|
||||||
if (! app()->runningUnitTests()) {
|
if (! app()->runningUnitTests()) {
|
||||||
// Test smtp server
|
// Test email connection
|
||||||
if ($request->input('mailDriver') === 'smtp') {
|
match ($request->input('mailDriver')) {
|
||||||
try {
|
'smtp' => ($this->testSMTPConnection)([
|
||||||
// Get credentials
|
'host' => $request->input('smtp.host'),
|
||||||
$credentials = [
|
'port' => $request->input('smtp.port'),
|
||||||
'smtp' => [
|
'username' => $request->input('smtp.username'),
|
||||||
'driver' => 'smtp',
|
'password' => $request->input('smtp.password'),
|
||||||
'host' => $request->input('smtp.host'),
|
'encryption' => $request->input('smtp.encryption') ?? '',
|
||||||
'port' => $request->input('smtp.port'),
|
'email' => $request->input('smtp.email'),
|
||||||
'username' => $request->input('smtp.username'),
|
]),
|
||||||
'password' => $request->input('smtp.password'),
|
'mailgun' => ($this->testMailgunConnection)([
|
||||||
'encryption' => $request->input('smtp.encryption') ?? '',
|
'domain' => $request->input('mailgun.domain'),
|
||||||
'from.address' => $request->input('smtp.email') ?? $request->input('smtp.username'),
|
'secret' => $request->input('mailgun.secret'),
|
||||||
'from.name' => $request->input('smtp.email') ?? $request->input('smtp.username'),
|
'endpoint' => $request->input('mailgun.endpoint'),
|
||||||
],
|
]),
|
||||||
];
|
};
|
||||||
|
|
||||||
// Set temporary mail connection
|
|
||||||
config(['mail' => $credentials['smtp']]);
|
|
||||||
|
|
||||||
$sender = $request->input('smtp.email') ?? $request->input('smtp.username');
|
|
||||||
|
|
||||||
// Send test email
|
|
||||||
Mail::to('test@hi5ve.digital')->send(new TestMail($sender));
|
|
||||||
} catch (TransportException|LogicException $error) {
|
|
||||||
return response([
|
|
||||||
'type' => 'mailer-connection-error',
|
|
||||||
'title' => 'Mail Connection Error',
|
|
||||||
'message' => $error->getMessage(),
|
|
||||||
], 401);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$mail = [
|
$mail = [
|
||||||
'log' => [
|
'log' => [
|
||||||
@@ -61,7 +49,7 @@ class StoreEmailCredentialsController
|
|||||||
'MAIL_DRIVER' => 'postmark',
|
'MAIL_DRIVER' => 'postmark',
|
||||||
'POSTMARK_TOKEN' => $request->input('postmark.token'),
|
'POSTMARK_TOKEN' => $request->input('postmark.token'),
|
||||||
],
|
],
|
||||||
'smtp' => [
|
'smtp' => [
|
||||||
'MAIL_DRIVER' => 'smtp',
|
'MAIL_DRIVER' => 'smtp',
|
||||||
'MAIL_HOST' => $request->input('smtp.host'),
|
'MAIL_HOST' => $request->input('smtp.host'),
|
||||||
'MAIL_PORT' => $request->input('smtp.port'),
|
'MAIL_PORT' => $request->input('smtp.port'),
|
||||||
@@ -96,6 +84,6 @@ class StoreEmailCredentialsController
|
|||||||
Artisan::call('config:cache');
|
Artisan::call('config:cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('Done', 204);
|
return response()->json('Done', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\SetupWizard\Controllers;
|
namespace Domain\SetupWizard\Controllers;
|
||||||
|
|
||||||
use Mail;
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Aws\S3\Exception\S3Exception;
|
|
||||||
use Domain\Settings\Mail\TestMail;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use League\Flysystem\UnableToWriteFile;
|
|
||||||
use Domain\Settings\DTO\S3CredentialsData;
|
use Domain\Settings\DTO\S3CredentialsData;
|
||||||
use Domain\Settings\Actions\TestS3ConnectionAction;
|
use Domain\Settings\Actions\TestS3ConnectionAction;
|
||||||
use Symfony\Component\Mailer\Exception\LogicException;
|
use Domain\Settings\Actions\TestSMTPConnectionAction;
|
||||||
use Symfony\Component\Mailer\Exception\TransportException;
|
use Domain\Settings\Actions\TestMailgunConnectionAction;
|
||||||
use Domain\SetupWizard\Requests\StoreEnvironmentSetupRequest;
|
use Domain\SetupWizard\Requests\StoreEnvironmentSetupRequest;
|
||||||
|
|
||||||
class StoreEnvironmentSettingsController extends Controller
|
class StoreEnvironmentSettingsController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private TestS3ConnectionAction $testS3Connection,
|
private TestS3ConnectionAction $testS3Connection,
|
||||||
|
private TestSMTPConnectionAction $testSMTPConnection,
|
||||||
|
private TestMailgunConnectionAction $testMailgunConnection,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,54 +24,29 @@ class StoreEnvironmentSettingsController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
StoreEnvironmentSetupRequest $request,
|
StoreEnvironmentSetupRequest $request,
|
||||||
): Response {
|
): JsonResponse {
|
||||||
if (! app()->runningUnitTests()) {
|
if (! app()->runningUnitTests()) {
|
||||||
// Test s3 credentials
|
// Test s3 credentials
|
||||||
if ($request->input('storage.driver') !== 'local') {
|
if ($request->input('storage.driver') !== 'local') {
|
||||||
try {
|
($this->testS3Connection)(S3CredentialsData::fromRequest($request));
|
||||||
// connect to the s3
|
|
||||||
($this->testS3Connection)(S3CredentialsData::fromRequest($request));
|
|
||||||
} catch (S3Exception | UnableToWriteFile $error) {
|
|
||||||
return response([
|
|
||||||
'type' => 's3-connection-error',
|
|
||||||
'title' => 'S3 Connection Error',
|
|
||||||
'message' => $error->getMessage(),
|
|
||||||
], 401);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test smtp server
|
// Test email connection
|
||||||
if ($request->input('mailDriver') === 'smtp') {
|
match ($request->input('mailDriver')) {
|
||||||
try {
|
'smtp' => ($this->testSMTPConnection)([
|
||||||
// Get credentials
|
'host' => $request->input('smtp.host'),
|
||||||
$credentials = [
|
'port' => $request->input('smtp.port'),
|
||||||
'smtp' => [
|
'username' => $request->input('smtp.username'),
|
||||||
'driver' => 'smtp',
|
'password' => $request->input('smtp.password'),
|
||||||
'host' => $request->input('smtp.host'),
|
'encryption' => $request->input('smtp.encryption') ?? '',
|
||||||
'port' => $request->input('smtp.port'),
|
'email' => $request->input('smtp.email'),
|
||||||
'username' => $request->input('smtp.username'),
|
]),
|
||||||
'password' => $request->input('smtp.password'),
|
'mailgun' => ($this->testMailgunConnection)([
|
||||||
'encryption' => $request->input('smtp.encryption') ?? '',
|
'domain' => $request->input('mailgun.domain'),
|
||||||
'from.address' => $request->input('smtp.email') ?? $request->input('smtp.username'),
|
'secret' => $request->input('mailgun.secret'),
|
||||||
'from.name' => $request->input('smtp.email') ?? $request->input('smtp.username'),
|
'endpoint' => $request->input('mailgun.endpoint'),
|
||||||
],
|
]),
|
||||||
];
|
};
|
||||||
|
|
||||||
// Set temporary mail connection
|
|
||||||
config(['mail' => $credentials['smtp']]);
|
|
||||||
|
|
||||||
$sender = $request->input('smtp.email') ?? $request->input('smtp.username');
|
|
||||||
|
|
||||||
// Send test email
|
|
||||||
Mail::to('test@hi5ve.digital')->send(new TestMail($sender));
|
|
||||||
} catch (TransportException|LogicException $error) {
|
|
||||||
return response([
|
|
||||||
'type' => 'mailer-connection-error',
|
|
||||||
'title' => 'Mail Connection Error',
|
|
||||||
'message' => $error->getMessage(),
|
|
||||||
], 401);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$setup = [
|
$setup = [
|
||||||
'broadcasting' => [
|
'broadcasting' => [
|
||||||
@@ -118,7 +91,7 @@ class StoreEnvironmentSettingsController extends Controller
|
|||||||
'MAIL_DRIVER' => 'postmark',
|
'MAIL_DRIVER' => 'postmark',
|
||||||
'POSTMARK_TOKEN' => $request->input('postmark.token'),
|
'POSTMARK_TOKEN' => $request->input('postmark.token'),
|
||||||
],
|
],
|
||||||
'smtp' => [
|
'smtp' => [
|
||||||
'MAIL_DRIVER' => 'smtp',
|
'MAIL_DRIVER' => 'smtp',
|
||||||
'MAIL_HOST' => $request->input('smtp.host'),
|
'MAIL_HOST' => $request->input('smtp.host'),
|
||||||
'MAIL_PORT' => $request->input('smtp.port'),
|
'MAIL_PORT' => $request->input('smtp.port'),
|
||||||
@@ -174,6 +147,6 @@ class StoreEnvironmentSettingsController extends Controller
|
|||||||
Artisan::call('config:cache');
|
Artisan::call('config:cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('Done', 204);
|
return response()->json('Done', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
namespace Support\Demo\Actions;
|
namespace Support\Demo\Actions;
|
||||||
|
|
||||||
use ByteUnits\Metric;
|
use ByteUnits\Metric;
|
||||||
use Domain\Sharing\Resources\ShareResource;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Domain\Files\Requests\UploadRequest;
|
use Domain\Files\Requests\UploadRequest;
|
||||||
|
|
||||||
|
|||||||
@@ -121,9 +121,10 @@ class UpgradingVersionsController
|
|||||||
public function upgrade_to_2_0_16(): void
|
public function upgrade_to_2_0_16(): void
|
||||||
{
|
{
|
||||||
($this->updateLanguageStrings)([
|
($this->updateLanguageStrings)([
|
||||||
'write_feedback' => 'Help Us Improve',
|
'write_feedback' => 'Help Us Improve',
|
||||||
'change_password' => 'Security & API',
|
'change_password' => 'Security & API',
|
||||||
'shared.empty_shared' => "Nothing Shared Yet",
|
'shared.empty_shared' => 'Nothing Shared Yet',
|
||||||
|
'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Artisan::call('cache:clear');
|
Artisan::call('cache:clear');
|
||||||
|
|||||||
Reference in New Issue
Block a user