ContextCurrentUserAuth.php in TMGMT Translator Smartling 8
File
src/Context/ContextCurrentUserAuth.php
View source
<?php
namespace Drupal\tmgmt_smartling\Context;
use Drupal\Core\Session\AccountInterface;
use Drupal\tmgmt_smartling\Exceptions\WrongUsernameException;
class ContextCurrentUserAuth {
protected $currentAccount;
public function __construct(AccountInterface $account) {
$this->currentAccount = $account;
}
public function getCookies($name) {
if ($this->currentAccount
->getAccountName() !== $name) {
throw new WrongUsernameException('You tried to authenticate with a username that is different from the current user. This feature wasn\'t implemented yet.');
}
return session_name() . "=" . session_id();
}
public function getCurrentAccount() {
return $this->currentAccount;
}
}