Completed
Push — master ( 33476c...427ebd )
by Bertrand
09:14
created

SessionAuthGateway::wikiSessionId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
use Illuminate\Support\Facades\Session;
11
12
class SessionAuthGateway implements AuthGateway
13
{
14
    public function current(): ?User
15
    {
16
        $userModel = Auth::user();
17
        if(!isset($userModel)){
18
            return null;
19
        }
20
        return new User($userModel->uuid, $userModel->email, $userModel->firstname, $userModel->lastname, $userModel->organization_id);
21
    }
22
23
    public function log(User $u)
24
    {
25
        $authenticate = \App\User::where('uuid', $u->id())->first();
26
        Auth::login($authenticate, true);
27
    }
28
29
    public function wikiSessionId():? string
30
    {
31
        return Session::get('wiki_session_id');
32
    }
33
34
}
35