mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for test
This commit is contained in:
parent
0079e52b85
commit
ba672f6fdd
@ -45,9 +45,6 @@ class UpdateUserRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
// if (isset($input['company_user']) && ! auth()->user()->isAdmin()) {
|
||||
// unset($input['company_user']);
|
||||
// }
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -60,12 +60,6 @@ class UniqueUserRule implements Rule
|
||||
*/
|
||||
private function checkIfEmailExists($email) : bool
|
||||
{
|
||||
$current_db = config('database.default');
|
||||
|
||||
$result = MultiDB::checkUserEmailExists($email);
|
||||
|
||||
MultiDB::setDb($current_db);
|
||||
|
||||
return $result;
|
||||
return MultiDB::checkUserEmailExists($email);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use Illuminate\Contracts\Validation\Rule;
|
||||
*/
|
||||
class AttachableUser implements Rule
|
||||
{
|
||||
public $message;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -39,7 +40,7 @@ class AttachableUser implements Rule
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Cannot add the same user to the same company";
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,9 +64,16 @@ class AttachableUser implements Rule
|
||||
->where('company_id', auth()->user()->company()->id)
|
||||
->exists();
|
||||
|
||||
if($user_already_attached)
|
||||
//If the user is already attached or isn't link to this account - return false
|
||||
if($user_already_attached) {
|
||||
$this->message = ctrans('texts.user_duplicate_error');
|
||||
return false;
|
||||
}
|
||||
|
||||
if($user->account_id != auth()->user()->account_id){
|
||||
$this->message = ctrans('texts.user_cross_linked_error');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -26,14 +26,7 @@ class ValidUserForCompany implements Rule
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$current_db = config('database.default');
|
||||
|
||||
$result = MultiDB::checkUserAndCompanyCoExist($value, auth()->user()->company()->company_key, auth()->user()->company()->id);
|
||||
|
||||
|
||||
MultiDB::setDb($current_db);
|
||||
|
||||
return $result;
|
||||
return MultiDB::checkUserAndCompanyCoExist($value, auth()->user()->company()->company_key, auth()->user()->company()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,7 +423,8 @@ class Import implements ShouldQueue
|
||||
$rules = [
|
||||
'*.first_name' => ['string'],
|
||||
'*.last_name' => ['string'],
|
||||
'*.email' => ['distinct'],
|
||||
//'*.email' => ['distinct'],
|
||||
'*.email' => ['distinct', 'email', new ValidUserForCompany(), new AttachableUser()],
|
||||
];
|
||||
|
||||
// if (config('ninja.db.multi_db_enabled')) {
|
||||
|
@ -106,8 +106,8 @@ class MultiDB
|
||||
$current_db = config('database.default');
|
||||
|
||||
foreach (self::$dbs as $db) {
|
||||
if (User::on($db)->where(['email' => $email])->get()->count() >= 1) { // if user already exists, validation will fail
|
||||
if (Company::on($db)->where(['company_key' => $company_key])->get()->count() >= 1) {
|
||||
if (User::on($db)->where(['email' => $email])->exists()) {
|
||||
if (Company::on($db)->where(['company_key' => $company_key])->exists()) {
|
||||
self::setDb($current_db);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -38,7 +38,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->invoice->next_send_date = null;
|
||||
$this->invoice->save();
|
||||
|
||||
return; //exit early
|
||||
return $this->invoice; //exit early
|
||||
}
|
||||
|
||||
$date_collection = collect();
|
||||
|
@ -4252,6 +4252,8 @@ $LANG = array(
|
||||
'contact_details' => 'Contact Details',
|
||||
'download_backup_subject' => 'Your company backup is ready for download',
|
||||
'account_passwordless_login' => 'Account passwordless login',
|
||||
'user_duplicate_error' => 'Cannot add the same user to the same company',
|
||||
'user_cross_linked_error' => 'User exists but cannot be crossed linked to multiple accounts',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -25,7 +25,6 @@ class CheckRemindersTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
use MakesReminders;
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
|
@ -192,10 +192,10 @@ trait MockAccountData
|
||||
|
||||
if (! $user) {
|
||||
$user = User::factory()->create([
|
||||
'account_id' => $this->account->id,
|
||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||
'email' => 'user@example.com',
|
||||
]);
|
||||
'account_id' => $this->account->id,
|
||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||
'email' => 'user@example.com',
|
||||
]);
|
||||
}
|
||||
|
||||
$user->password = Hash::make('ALongAndBriliantPassword');
|
||||
|
Loading…
x
Reference in New Issue
Block a user