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

SessionAuthGateway   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 7 2
A log() 0 4 1
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