public function authenticate(TokenInterface $token)
 {
     $user = $this->userProvider->loadUserById($token->getUserId());
     if ($user && $token instanceof UserToken) {
         $token->setUser($user);
         global $_G;
         $em = \Dev::getDoctrine()->getManager();
         $user->setupDiscuzRoles($em, $_G);
         return $token;
     }
     if (\Dev::getContainer()->getParameter('kernel.debug')) {
         throw new AuthenticationException('The app authentication failed.');
     } else {
         if (\Dev::getContainer()->getParameter('debug_redirects')) {
             \Dev::dump('The app authentication failed.');
             exit;
         }
         $host = \Dev::getContainer()->getParameter('sf.web_host');
         header('location:' . $host);
         exit;
     }
 }