Completed
Push — master ( 5b54fc...16c96d )
by Bertrand
14:42
created

SessionAuthGateway::current()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace App\Src\UseCases\Infra\Gateway;
5
6
7
use App\Src\UseCases\Domain\Shared\Gateway\AuthGateway;
8
use App\Src\UseCases\Domain\User;
9
use Illuminate\Support\Facades\Auth;
10
11
class SessionAuthGateway implements AuthGateway
12
{
13
    public function current(): ?User
14
    {
15
        $userModel = Auth::user();
16
        if(!isset($userModel)){
17
            return null;
18
        }
19
        return new User($userModel->uuid, $userModel->email, $userModel->firstname, $userModel->lastname, $userModel->organization_id);
20
    }
21
22
    public function log(User $u)
23
    {
24
        $autenticable = \App\User::where('uuid', $u->id())->first();
25
        Auth::login($autenticable);
26
    }
27
28
}
29