MouchardCompleterAuth.php 899 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?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;

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

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

        return $this;
    }

}