Merge pull request #5376 from turbo124/v5-develop

Set password for new users.
This commit is contained in:
David Bomba 2021-04-08 20:19:51 +10:00 committed by GitHub
commit d5e0e4335b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 66 additions and 47 deletions

View File

@ -55,5 +55,7 @@ PHANTOMJS_PDF_GENERATION=true
PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=secret
UPDATE_SECRET=
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5

View File

@ -12,7 +12,6 @@
namespace App\Http\Controllers;
use \Illuminate\Support\Facades\DB;
use App\Http\Requests\Setup\CheckDatabaseRequest;
use App\Http\Requests\Setup\CheckMailRequest;
use App\Http\Requests\Setup\StoreSetupRequest;
@ -20,6 +19,7 @@ use App\Jobs\Account\CreateAccount;
use App\Jobs\Util\VersionCheck;
use App\Models\Account;
use App\Utils\CurlUtils;
use App\Utils\Ninja;
use App\Utils\SystemHealth;
use App\Utils\Traits\AppSetup;
use Beganovich\Snappdf\Snappdf;
@ -29,10 +29,12 @@ use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use \Illuminate\Support\Facades\DB;
/**
* Class SetupController.
@ -267,4 +269,29 @@ class SetupController extends Controller
return response([], 500);
}
}
public function update()
{
if( Ninja::isNinja() || !request()->has('secret') || (request()->input('secret') != config('ninja.update_secret')) )
return redirect('/');
$cacheCompiled = base_path('bootstrap/cache/compiled.php');
if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); }
$cacheServices = base_path('bootstrap/cache/services.php');
if (file_exists($cacheServices)) { unlink ($cacheServices); }
Artisan::call('clear-compiled');
Artisan::call('cache:clear');
Artisan::call('debugbar:clear');
Artisan::call('route:clear');
Artisan::call('view:clear');
Artisan::call('config:clear');
Cache::flush();
Artisan::call('migrate', ['--force' => true]);
Artisan::call('db:seed', ['--force' => true]);
return redirect('/?clear_cache=true');
}
}

View File

@ -13,6 +13,7 @@
namespace App\Http\Controllers\Traits;
use App\Models\User;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\UserSessionAttributes;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Hash;
@ -23,6 +24,7 @@ use Illuminate\Support\Facades\Hash;
trait VerifiesUserEmail
{
use UserSessionAttributes;
use MakesHash;
/**
* @return RedirectResponse
@ -37,14 +39,14 @@ trait VerifiesUserEmail
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
}
if (is_null($user->password) || empty($user->password)) {
return $this->render('auth.confirmation_with_password', ['root' => 'themes']);
}
$user->email_verified_at = now();
$user->confirmation_code = null;
$user->save();
if (is_null($user->password) || empty($user->password) || Hash::check('', $user->password)) {
return $this->render('auth.confirmation_with_password', ['root' => 'themes', 'user_id' => $user->hashed_id]);
}
return $this->render('auth.confirmed', [
'root' => 'themes',
'message' => ctrans('texts.security_confirmation'),
@ -53,16 +55,13 @@ trait VerifiesUserEmail
public function confirmWithPassword()
{
$user = User::where('confirmation_code', request()->confirmation_code)->first();
if (! $user) {
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
}
$user = User::where('id', $this->decodePrimaryKey(request()->user_id))->firstOrFail();
request()->validate([
'password' => ['required', 'min:6', 'confirmed'],
'password' => ['required', 'min:6'],
]);
$user->password = Hash::make(request()->password);
$user->email_verified_at = now();

View File

@ -127,7 +127,7 @@ class SubscriptionService
];
$response = $this->triggerWebhook($context);
nlog($response);
return $response;
}
@ -269,11 +269,23 @@ class SubscriptionService
//scan for any notification we are required to send
}
/**
* Get the single charge products for the
* subscription
*
* @return ?Product Collection
*/
public function products()
{
return Product::whereIn('id', $this->transformKeys(explode(",", $this->subscription->product_ids)))->get();
}
/**
* Get the recurring products for the
* subscription
*
* @return ?Product Collection
*/
public function recurring_products()
{
return Product::whereIn('id', $this->transformKeys(explode(",", $this->subscription->recurring_product_ids)))->get();

View File

@ -38,7 +38,7 @@ return [
'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'),
'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'
'preconfigured_install' => env('PRECONFIGURED_INSTALL',false),
'update_secret' => env('UPDATE_SECRET', false),
// Settings used by invoiceninja.com
'terms_of_service_url' => [

View File

@ -623,7 +623,7 @@ class CreateUsersTable extends Migration
$t->unsignedInteger('vendor_id')->nullable();
$t->unsignedInteger('status_id')->index();
$t->text('number')->nullable();
$t->string('number')->nullable();
$t->float('discount')->default(0);
$t->boolean('is_amount_discount')->default(false);
@ -672,6 +672,7 @@ class CreateUsersTable extends Migration
$t->softDeletes('deleted_at', 6);
$t->index(['company_id', 'deleted_at']);
$t->unique(['company_id', 'number']);
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade')->onUpdate('cascade');
$t->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade');
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
@ -960,7 +961,7 @@ class CreateUsersTable extends Migration
$t->unsignedInteger('exchange_currency_id');
$t->index(['company_id', 'deleted_at']);
$t->unique(['company_id', 'number']);
$t->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade');
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade')->onUpdate('cascade');
$t->foreign('client_contact_id')->references('id')->on('client_contacts')->onDelete('cascade')->onUpdate('cascade');

View File

@ -25,15 +25,18 @@ class IdNumberFieldsForMissingEntities extends Migration
{
Schema::table('expenses', function (Blueprint $table) {
$table->string('number')->nullable();
$table->unique(['company_id', 'number']);
});
Schema::table('tasks', function (Blueprint $table) {
$table->string('number')->nullable();
$table->unique(['company_id', 'number']);
});
Schema::table('vendors', function (Blueprint $table) {
$table->text('vendor_hash')->nullable();
$table->text('public_notes')->nullable();
$table->unique(['company_id', 'number']);
});
Schema::table('vendor_contacts', function (Blueprint $table) {

View File

@ -24,6 +24,7 @@ class ProjectNumberColumn extends Migration
{
Schema::table('projects', function ($table) {
$table->string('number')->nullable();
$table->unique(['company_id', 'number']);
});
Schema::table('expenses', function ($t) {

View File

@ -23,10 +23,13 @@ class AddNumberFieldToClientsAndVendors extends Migration
Schema::table('clients', function (Blueprint $table) {
$table->string('id_number')->nullable();
$table->unique(['company_id', 'number']);
});
Schema::table('vendors', function (Blueprint $table) {
$table->string('id_number')->nullable();
$table->unique(['company_id', 'number']);
});
}

View File

@ -13,38 +13,7 @@ class AddUniqueConstraintsOnAllEntities extends Migration
*/
public function up()
{
Schema::table('expenses', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('tasks', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('vendors', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('payments', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('projects', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('clients', function (Blueprint $table) {
$table->unique(['company_id', 'number']);
});
Schema::table('recurring_invoices', function (Blueprint $table) {
$table->string('number')->change();
$table->unique(['company_id', 'number']);
});
Schema::table('recurring_invoice_invitations', function (Blueprint $table) {
$table->unique(['client_contact_id', 'recurring_invoice_id'],'recur_invoice_client_unique');
});
}

View File

@ -11,6 +11,7 @@
<form action="{{ url()->current() }}" method="post" class="mt-6">
@csrf
<input type="hidden" name="user_id" value="{{ $user_id }}">
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
<input type="password" name="password" id="password"

View File

@ -8,6 +8,7 @@ Route::get('/', 'BaseController@flutterRoute')->middleware('guest');
Route::get('setup', 'SetupController@index')->middleware('guest');
Route::post('setup', 'SetupController@doSetup')->middleware('guest');
Route::get('update', 'SetupController@update')->middleware('guest');
Route::post('setup/check_db', 'SetupController@checkDB')->middleware('guest');
Route::post('setup/check_mail', 'SetupController@checkMail')->middleware('guest');