public function ensureLogin()
{
if (!$this->session()->isActive()) {
if (count($tokens = $this->session()->getTokens()->all()) == 1) {
$token = array_shift($tokens);
} elseif (!empty($email = $this->getConfig()->get('user'))) {
$token = $this->session()->getTokens()->get($email);
} else {
throw new \Exception('You are not logged in. Run `auth:login` to authenticate or `help auth:login` for more info.');
}
$token->logIn();
}
}