MouchardCompleterAuth.php 870 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace UnicaenAuth\Mouchard;

use UnicaenApp\Mouchard\MouchardCompleterInterface;
use UnicaenApp\Mouchard\MouchardMessage;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;

/**
 * Interface MouchardCompleterInterface
 *
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 * @package UnicaenApp\Mouchard
 */
class MouchardCompleterAuth implements MouchardCompleterInterface
{
    use UserContextServiceAwareTrait;

    /**
     * @return $this
     */
    public function complete(MouchardMessage $message)
    {
24
        $user = $this->getServiceUserContext()->getDbUser();
25
26
27
28
        if ($user){
            $message->setUser($user->getDisplayName());
            $message->setLogin($user->getUsername());
        }
29

30
31
32
33
34
35
        $message->setRole((string)$this->getServiceUserContext()->getSelectedIdentityRole());

        return $this;
    }

}