mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #4444 from beganovich/v5-setup-fixes
(v5) Setup fixes & improvements
This commit is contained in:
commit
1d611f3bc6
@ -847,7 +847,7 @@ class InvoiceController extends BaseController
|
||||
$file = base_path("public/storage/{$file_path}");
|
||||
|
||||
return response()->download($file, basename($file));
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return response(['message' => 'Oops, something went wrong. Make sure you have symlink to storage/ in public/ directory.'], 500);
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,34 @@ class SetupController extends Controller
|
||||
return response('Oops, something went wrong. Check your logs.'); /* We should never reach this block, but just in case. */
|
||||
}
|
||||
|
||||
$mail_driver = $request->input('mail_driver');
|
||||
|
||||
if (!$this->failsafeMailCheck($request)) {
|
||||
$mail_driver = 'log';
|
||||
try {
|
||||
$db = SystemHealth::dbCheck($request);
|
||||
|
||||
if ($db['success'] == false) {
|
||||
throw new \Exception($db['message']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to database was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$smtp = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($smtp['success'] == false) {
|
||||
throw new \Exception($smtp['message']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to mail server was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
$mail_driver = $request->input('mail_driver');
|
||||
|
||||
$url = $request->input('url');
|
||||
|
||||
if (substr($url, -1) != '/') {
|
||||
@ -84,8 +106,8 @@ class SetupController extends Controller
|
||||
'REQUIRE_HTTPS' => $request->input('https') ? 'true' : 'false',
|
||||
'APP_DEBUG' => $request->input('debug') ? 'true' : 'false',
|
||||
|
||||
'DB_HOST1' => $request->input('host'),
|
||||
'DB_DATABASE1' => $request->input('database'),
|
||||
'DB_HOST1' => $request->input('db_host'),
|
||||
'DB_DATABASE1' => $request->input('db_database'),
|
||||
'DB_USERNAME1' => $request->input('db_username'),
|
||||
'DB_PASSWORD1' => $request->input('db_password'),
|
||||
|
||||
@ -171,12 +193,12 @@ class SetupController extends Controller
|
||||
public function checkMail(CheckMailRequest $request)
|
||||
{
|
||||
try {
|
||||
$response_array = SystemHealth::testMailServer($request);
|
||||
$response = SystemHealth::testMailServer($request);
|
||||
|
||||
if (count($response_array) == 0) {
|
||||
if ($response['success']) {
|
||||
return response([], 200);
|
||||
} else {
|
||||
return response()->json(['message' => $response_array[0]], 400);
|
||||
return response()->json(['message' => $response['message']], 400);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
info(['message' => $e->getMessage(), 'action' => 'SetupController::checkMail()']);
|
||||
@ -187,10 +209,10 @@ class SetupController extends Controller
|
||||
|
||||
private function failsafeMailCheck($request)
|
||||
{
|
||||
$response_array = SystemHealth::testMailServer($request);
|
||||
$response = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($response_array instanceof Response) {
|
||||
return true;
|
||||
if ($response['success']) {
|
||||
true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -34,9 +34,9 @@ class CheckDatabaseRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'host' => ['required'],
|
||||
'database' => ['required'],
|
||||
'username' => ['required'],
|
||||
'db_host' => ['required'],
|
||||
'db_database' => ['required'],
|
||||
'db_username' => ['required'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -36,14 +36,13 @@ class CheckMailRequest extends Request
|
||||
info($this->driver);
|
||||
|
||||
return [
|
||||
'driver' => ['required', 'in:smtp,mail,sendmail,log'],
|
||||
'from_name' => ['required_unless:driver,log'],
|
||||
'from_address' => ['required_unless:driver,log'],
|
||||
'username' => ['required_unless:driver,log'],
|
||||
'host' => ['required_unless:driver,log'],
|
||||
'port' => ['required_unless:driver,log'],
|
||||
'encryption' => ['required_unless:driver,log'],
|
||||
'password' => ['required_unless:driver,log'],
|
||||
'mail_driver' => 'required',
|
||||
'encryption' => 'required_unless:mail_driver,log',
|
||||
'mail_host' => 'required_unless:mail_driver,log',
|
||||
'mail_username' => 'required_unless:mail_driver,log',
|
||||
'mail_name' => 'required_unless:mail_driver,log',
|
||||
'mail_address' => 'required_unless:mail_driver,log',
|
||||
'mail_password' => 'required_unless:mail_driver,log',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class StoreSetupRequest extends Request
|
||||
/*System*/
|
||||
'url' => 'required',
|
||||
/*Database*/
|
||||
'host' => 'required',
|
||||
'database' => 'required',
|
||||
'db_host' => 'required',
|
||||
'db_database' => 'required',
|
||||
'db_username' => 'required',
|
||||
'db_password' => '',
|
||||
/*Mail driver*/
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Http\Requests\Setup\CheckDatabaseRequest;
|
||||
use App\Http\Requests\Setup\CheckMailRequest;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\TestMailServer;
|
||||
use Exception;
|
||||
@ -160,11 +158,11 @@ class SystemHealth
|
||||
{
|
||||
$result = ['success' => false];
|
||||
|
||||
if ($request && $request instanceof CheckDatabaseRequest) {
|
||||
config(['database.connections.db-ninja-01.host'=> $request->input('host')]);
|
||||
config(['database.connections.db-ninja-01.database'=> $request->input('database')]);
|
||||
config(['database.connections.db-ninja-01.username'=> $request->input('username')]);
|
||||
config(['database.connections.db-ninja-01.password'=> $request->input('password')]);
|
||||
if ($request) {
|
||||
config(['database.connections.db-ninja-01.host'=> $request->input('db_host')]);
|
||||
config(['database.connections.db-ninja-01.database'=> $request->input('db_database')]);
|
||||
config(['database.connections.db-ninja-01.username'=> $request->input('db_username')]);
|
||||
config(['database.connections.db-ninja-01.password'=> $request->input('db_password')]);
|
||||
config(['database.default' => 'db-ninja-01']);
|
||||
|
||||
DB::purge('db-ninja-01');
|
||||
@ -191,6 +189,7 @@ class SystemHealth
|
||||
} catch (Exception $e) {
|
||||
$result[] = [config('database.connections.'.config('database.default').'.database') => false];
|
||||
$result['success'] = false;
|
||||
$result['message'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,35 +208,24 @@ class SystemHealth
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($request && $request instanceof CheckMailRequest) {
|
||||
config(['mail.driver' => $request->input('driver')]);
|
||||
config(['mail.host' => $request->input('host')]);
|
||||
config(['mail.port' => $request->input('port')]);
|
||||
config(['mail.from.address' => $request->input('from_address')]);
|
||||
config(['mail.from.name' => $request->input('from_name')]);
|
||||
if ($request) {
|
||||
config(['mail.driver' => $request->input('mail_driver')]);
|
||||
config(['mail.host' => $request->input('mail_host')]);
|
||||
config(['mail.port' => $request->input('mail_port')]);
|
||||
config(['mail.from.address' => $request->input('mail_address')]);
|
||||
config(['mail.from.name' => $request->input('mail_name')]);
|
||||
config(['mail.encryption' => $request->input('encryption')]);
|
||||
config(['mail.username' => $request->input('username')]);
|
||||
config(['mail.password' => $request->input('password')]);
|
||||
config(['mail.username' => $request->input('mail_username')]);
|
||||
config(['mail.password' => $request->input('mail_password')]);
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to(config('mail.from.address'))->send(new TestMailServer('Email Server Works!', config('mail.from.address')));
|
||||
} catch (Exception $e) {
|
||||
return [$e->getMessage()];
|
||||
return ['success' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
|
||||
/*
|
||||
* 'message' => 'count(): Parameter must be an array or an object that implements Countable',
|
||||
* 'action' => 'SetupController::checkMail()',
|
||||
*
|
||||
* count(Mail::failures())
|
||||
*/
|
||||
|
||||
if (Mail::failures() > 0) {
|
||||
return Mail::failures();
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Success'], 200);
|
||||
return ['success' => true];
|
||||
}
|
||||
|
||||
private static function checkEnvWritable()
|
||||
|
81
package-lock.json
generated
81
package-lock.json
generated
@ -1508,64 +1508,22 @@
|
||||
"integrity": "sha1-DeiJpgEgOQmw++B7iTjcIdLpZ7w="
|
||||
},
|
||||
"adjust-sourcemap-loader": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/adjust-sourcemap-loader/-/adjust-sourcemap-loader-2.0.0.tgz",
|
||||
"integrity": "sha512-4hFsTsn58+YjrU9qKzML2JSSDqKvN8mUGQ0nNIrfPi8hmIONT4L3uUaT6MKdMsZ9AjsU6D2xDkZxCkbQPxChrA==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/adjust-sourcemap-loader/-/adjust-sourcemap-loader-3.0.0.tgz",
|
||||
"integrity": "sha512-YBrGyT2/uVQ/c6Rr+t6ZJXniY03YtHGMJQYal368burRGYKqhx9qGTWqcBU5s1CwYY9E/ri63RYyG1IacMZtqw==",
|
||||
"requires": {
|
||||
"assert": "1.4.1",
|
||||
"camelcase": "5.0.0",
|
||||
"loader-utils": "1.2.3",
|
||||
"object-path": "0.11.4",
|
||||
"regex-parser": "2.2.10"
|
||||
"loader-utils": "^2.0.0",
|
||||
"regex-parser": "^2.2.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
|
||||
"integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
|
||||
"requires": {
|
||||
"util": "0.10.3"
|
||||
}
|
||||
},
|
||||
"camelcase": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
||||
"integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA=="
|
||||
},
|
||||
"emojis-list": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz",
|
||||
"integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k="
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
|
||||
"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE="
|
||||
},
|
||||
"json5": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"loader-utils": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz",
|
||||
"integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
||||
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
||||
"requires": {
|
||||
"big.js": "^5.2.2",
|
||||
"emojis-list": "^2.0.0",
|
||||
"json5": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"util": {
|
||||
"version": "0.10.3",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
||||
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
|
||||
"requires": {
|
||||
"inherits": "2.0.1"
|
||||
"emojis-list": "^3.0.0",
|
||||
"json5": "^2.1.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6698,11 +6656,6 @@
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha1-HEfyct8nfzsdrwYWd9nILiMixg4="
|
||||
},
|
||||
"object-path": {
|
||||
"version": "0.11.4",
|
||||
"resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.4.tgz",
|
||||
"integrity": "sha1-NwrnUvvzfePqcKhhwju6iRVpGUk="
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
|
||||
@ -8192,9 +8145,9 @@
|
||||
}
|
||||
},
|
||||
"regex-parser": {
|
||||
"version": "2.2.10",
|
||||
"resolved": "https://registry.npmjs.org/regex-parser/-/regex-parser-2.2.10.tgz",
|
||||
"integrity": "sha512-8t6074A68gHfU8Neftl0Le6KTDwfGAj7IyjPIMSfikI2wJUTHDMaIq42bUsfVnj8mhx0R+45rdUXHGpN164avA=="
|
||||
"version": "2.2.11",
|
||||
"resolved": "https://registry.npmjs.org/regex-parser/-/regex-parser-2.2.11.tgz",
|
||||
"integrity": "sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q=="
|
||||
},
|
||||
"regexp.prototype.flags": {
|
||||
"version": "1.3.0",
|
||||
@ -8355,11 +8308,11 @@
|
||||
"integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo="
|
||||
},
|
||||
"resolve-url-loader": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.1.tgz",
|
||||
"integrity": "sha512-K1N5xUjj7v0l2j/3Sgs5b8CjrrgtC70SmdCuZiJ8tSyb5J+uk3FoeZ4b7yTnH6j7ngI+Bc5bldHJIa8hYdu2gQ==",
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.2.tgz",
|
||||
"integrity": "sha512-QEb4A76c8Mi7I3xNKXlRKQSlLBwjUV/ULFMP+G7n3/7tJZ8MG5wsZ3ucxP1Jz8Vevn6fnJsxDx9cIls+utGzPQ==",
|
||||
"requires": {
|
||||
"adjust-sourcemap-loader": "2.0.0",
|
||||
"adjust-sourcemap-loader": "3.0.0",
|
||||
"camelcase": "5.3.1",
|
||||
"compose-function": "3.0.3",
|
||||
"convert-source-map": "1.7.0",
|
||||
|
@ -28,7 +28,7 @@
|
||||
"jsignature": "^2.1.3",
|
||||
"laravel-mix": "^5.0.7",
|
||||
"lodash": "^4.17.20",
|
||||
"resolve-url-loader": "^3.1.0",
|
||||
"resolve-url-loader": "^3.1.2",
|
||||
"sass": "^1.26.10",
|
||||
"sass-loader": "^8.0.0",
|
||||
"tailwindcss": "^1.6.2"
|
||||
|
2
public/js/setup/setup.js
vendored
2
public/js/setup/setup.js
vendored
File diff suppressed because one or more lines are too long
@ -15,6 +15,6 @@
|
||||
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=85bcae0a646882e56b12",
|
||||
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45",
|
||||
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=fa54bb4229aba6b0817c",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=34b53878aeaca14a2b33",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=725362f2ed393909fc8b",
|
||||
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad"
|
||||
}
|
||||
|
22
resources/js/setup/setup.js
vendored
22
resources/js/setup/setup.js
vendored
@ -24,10 +24,10 @@ class Setup {
|
||||
|
||||
handleDatabaseCheck() {
|
||||
let data = {
|
||||
host: document.querySelector('input[name="host"]').value,
|
||||
database: document.querySelector('input[name="database"]').value,
|
||||
username: document.querySelector('input[name="db_username"]').value,
|
||||
password: document.querySelector('input[name="db_password"]').value,
|
||||
db_host: document.querySelector('input[name="db_host"]').value,
|
||||
db_database: document.querySelector('input[name="db_database"]').value,
|
||||
db_username: document.querySelector('input[name="db_username"]').value,
|
||||
db_password: document.querySelector('input[name="db_password"]').value,
|
||||
};
|
||||
|
||||
Axios.post('/setup/check_db', data)
|
||||
@ -39,17 +39,17 @@ class Setup {
|
||||
|
||||
handleSmtpCheck() {
|
||||
let data = {
|
||||
driver: document.querySelector('select[name="mail_driver"]').value,
|
||||
from_name: document.querySelector('input[name="mail_name"]').value,
|
||||
from_address: document.querySelector('input[name="mail_address"]')
|
||||
mail_driver: document.querySelector('select[name="mail_driver"]').value,
|
||||
mail_name: document.querySelector('input[name="mail_name"]').value,
|
||||
mail_address: document.querySelector('input[name="mail_address"]')
|
||||
.value,
|
||||
username: document.querySelector('input[name="mail_username"]')
|
||||
mail_username: document.querySelector('input[name="mail_username"]')
|
||||
.value,
|
||||
host: document.querySelector('input[name="mail_host"]').value,
|
||||
port: document.querySelector('input[name="mail_port"]').value,
|
||||
mail_host: document.querySelector('input[name="mail_host"]').value,
|
||||
mail_port: document.querySelector('input[name="mail_port"]').value,
|
||||
encryption: document.querySelector('select[name="encryption"]')
|
||||
.value,
|
||||
password: document.querySelector('input[name="mail_password"]')
|
||||
mail_password: document.querySelector('input[name="mail_password"]')
|
||||
.value,
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ FLUSH PRIVILEGES;
|
||||
{{ ctrans('texts.host') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="host" required value="{{ old('host') ?: 'localhost'}}">
|
||||
<input type="text" class="input w-full" name="db_host" required value="{{ old('host') ?: 'localhost'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
@ -46,7 +46,7 @@ FLUSH PRIVILEGES;
|
||||
{{ ctrans('texts.database') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="database" required value="{{ old('database') ?: 'db-ninja-01'}}">
|
||||
<input type="text" class="input w-full" name="db_database" required value="{{ old('database') ?: 'db-ninja-01'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
|
Loading…
Reference in New Issue
Block a user