mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:27:31 -05:00 
			
		
		
		
	fixes for adding users into the production system
This commit is contained in:
		
							parent
							
								
									539fc1dcfd
								
							
						
					
					
						commit
						f66c3076f1
					
				@ -33,6 +33,11 @@ class CanAddUserRule implements Rule
 | 
			
		||||
    public function passes($attribute, $value)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        /* If the user is active then we can add them to the company */
 | 
			
		||||
        if(User::where('email', request()->input('email'))->where('account_id', auth()->user()->account_id)->where('is_deleted',0)->exists())
 | 
			
		||||
            return true;
 | 
			
		||||
 | 
			
		||||
        /* Check that we have sufficient quota to allow this to happen */
 | 
			
		||||
        $count = CompanyUser::query()
 | 
			
		||||
                          ->where('company_user.account_id', auth()->user()->account_id)
 | 
			
		||||
                          ->join('users', 'users.id', '=', 'company_user.user_id')
 | 
			
		||||
 | 
			
		||||
@ -171,7 +171,7 @@ class Company extends BaseModel
 | 
			
		||||
 | 
			
		||||
    public function users()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->hasManyThrough(User::class, CompanyUser::class, 'company_id', 'id', 'id', 'user_id');
 | 
			
		||||
        return $this->hasManyThrough(User::class, CompanyUser::class, 'company_id', 'id', 'id', 'user_id')->withTrashed();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function expense_categories()
 | 
			
		||||
 | 
			
		||||
@ -189,6 +189,14 @@ class UserRepository extends BaseRepository
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (Ninja::isHosted()) {
 | 
			
		||||
            
 | 
			
		||||
            $count = User::where('account_id', auth()->user()->account_id)->count();
 | 
			
		||||
            if($count >= auth()->user()->account->num_users)
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $user->is_deleted = false;
 | 
			
		||||
        $user->save();
 | 
			
		||||
        $user->restore();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user