namespace BookStack\Api;
+use BookStack\Access\LoginService;
use BookStack\Exceptions\ApiAuthException;
use Illuminate\Auth\GuardHelpers;
use Illuminate\Contracts\Auth\Authenticatable;
*/
protected $request;
+ /**
+ * @var LoginService
+ */
+ protected $loginService;
+
/**
* The last auth exception thrown in this request.
*
/**
* ApiTokenGuard constructor.
*/
- public function __construct(Request $request)
+ public function __construct(Request $request, LoginService $loginService)
{
$this->request = $request;
+ $this->loginService = $loginService;
}
/**
- * @inheritDoc
+ * {@inheritdoc}
*/
public function user()
{
$this->validateToken($token, $secret);
+ if ($this->loginService->awaitingEmailConfirmation($token->user)) {
+ throw new ApiAuthException(trans('errors.email_confirmation_awaiting'));
+ }
+
return $token->user;
}
}
/**
- * @inheritDoc
+ * {@inheritdoc}
*/
public function validate(array $credentials = [])
{