We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
here is a code to return through the api route the user information but also to allow the logout.
Client side route in js (example for reactjs) :
function logout(evt) { axios.get(routing.oauthuri).then((response)=>{ window.location.href = response.data.oauth_uri+'/api/logout?uri='+window.location.origin }); }
Have a good day.
`/** * @Route("/api", name="app_api") * @return Response */ public function index(): Response { $user = $this->security->getUser(); $userInfo = []; $userInfo['username'] = $user->getId(); $userInfo['nickname'] = $user->getUserIdentifier(); $userInfo['email'] = $user->getEmail(); $userInfo['realusername'] = $user->getUsername(); $userInfo['roles'] = $user->getRoles(); return new JsonResponse($userInfo); }` /** * @Route("/api/logout", name="app_api_logout", methods="GET") * @param Request $request * @return RedirectResponse */ public function userLogoutAction(Request $request) { $error = ""; $user = $this->security->getUser()->getUserIdentifier(); $uri = $request->query->get('uri').'/logout'; $tokenObj = $this->em->getRepository(AccessToken::class)->findBy(['userIdentifier' => $user]); if(!empty($user)){ if (!empty($tokenObj)) { foreach ($tokenObj as $token) { $refreshToken = $this->em->getRepository(RefreshToken::class)->findBy(['accessToken' => $token->getIdentifier()]); if (!empty($tokenObj)) { foreach ($refreshToken as $rtoken) { $rtoken->revoke(); $this->em->flush(); } $token->revoke(); $this->em->flush(); } } } } else { $error = "Can't find access token"; } $response = new RedirectResponse($uri); $response->headers->clearCookie("PHPSESSID"); return $response; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
here is a code to return through the api route the user information but also to allow the logout.
Client side route in js (example for reactjs) :
function logout(evt) { axios.get(routing.oauthuri).then((response)=>{ window.location.href = response.data.oauth_uri+'/api/logout?uri='+window.location.origin }); }
Have a good day.
The text was updated successfully, but these errors were encountered: