1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #4463 from turbo124/v5-develop

Fix for User Validation
This commit is contained in:
David Bomba 2020-12-10 21:29:54 +11:00 committed by GitHub
commit 9227904c8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -17,6 +17,7 @@ use App\Http\Requests\Request;
use App\Http\ValidationRules\ValidUserForCompany; use App\Http\ValidationRules\ValidUserForCompany;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\User; use App\Models\User;
use Illuminate\Validation\Rule;
class StoreUserRequest extends Request class StoreUserRequest extends Request
{ {
@ -37,9 +38,11 @@ class StoreUserRequest extends Request
$rules['first_name'] = 'required|string|max:100'; $rules['first_name'] = 'required|string|max:100';
$rules['last_name'] = 'required|string|max:100'; $rules['last_name'] = 'required|string|max:100';
if (config('ninja.db.multi_db_enabled')) { if (config('ninja.db.multi_db_enabled'))
$rules['email'] = new ValidUserForCompany(); $rules['email'] = [new ValidUserForCompany(), Rule::unique('users')];
} else
$rules['email'] = Rule::unique('users');
if (auth()->user()->company()->account->isFreeHostedClient()) { if (auth()->user()->company()->account->isFreeHostedClient()) {
$rules['hosted_users'] = new CanAddUserRule(auth()->user()->company()->account); $rules['hosted_users'] = new CanAddUserRule(auth()->user()->company()->account);

View File

@ -11,6 +11,7 @@
namespace App\Models; namespace App\Models;
use App\Models\GatewayType;
use App\PaymentDrivers\BasePaymentDriver; use App\PaymentDrivers\BasePaymentDriver;
use App\Utils\Number; use App\Utils\Number;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@ -235,6 +236,9 @@ class CompanyGateway extends BaseModel
return false; return false;
} }
if($gateway_type_id == GatewayType::CUSTOM)
$gateway_type_id = GatewayType::CREDIT_CARD;
return $this->fees_and_limits->{$gateway_type_id}; return $this->fees_and_limits->{$gateway_type_id};
} }

View File

@ -95,7 +95,7 @@ class PaymentLibrariesSeeder extends Seeder
Gateway::query()->update(['visible' => 0]); Gateway::query()->update(['visible' => 0]);
Gateway::whereIn('id', [1,15,20,39])->update(['visible' => 1]); Gateway::whereIn('id', [1,15,20,39,55])->update(['visible' => 1]);
Gateway::all()->each(function ($gateway) { Gateway::all()->each(function ($gateway) {
$gateway->site_url = $gateway->getHelp(); $gateway->site_url = $gateway->getHelp();