SyncLdap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 37
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
A activateUsers() 0 5 1
1
<?php
2
3
namespace SET\Console\Commands;
4
5
use Carbon\Carbon;
6
use Illuminate\Console\Command;
7
use Illuminate\Support\Facades\Artisan;
8
use League\Flysystem\Exception;
9
use SET\User;
10
11
class SyncLdap extends Command
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'users:sync';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Sync users table with LDAP';
26
27
    /**
28
     * Execute the console command.
29
     *
30
     * @return Exception|null
31
     */
32
    public function handle()
33
    {
34
        if (config('auth.providers.users.driver') != 'adldap') {
35
            return new Exception('LDAP not setup. Syncing users will not work.');
36
        }
37
38
        Artisan::call('adldap:import');
39
        $this->activateUsers();
40
    }
41
42
    private function activateUsers()
43
    {
44
        User::whereBetween('created_at', [Carbon::now()->subMinutes(1), Carbon::now()])
45
            ->update(['status' => 'active']);
46
    }
47
}
48