Silverstripe Version:
4
Question:
doLogOut implementation
Details of your query go here
Hi all. I’m triyng to implement a LogoutHandler, but returns me a blank page.
I created a custom authenticator following the offical docs. Login works normally, but as I mentioned, /Security/logou link redirect to blank page without perform any logout.
Here’s my Handler code:
[code]
use SilverStripe\Security\MemberAuthenticator\LogoutHandler;
use SilverStripe\Security\Security;
use SilverStripe\Security\Member;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Security\IdentityStore;
use SilverStripe\Control\HTTPResponse;
/**
- Clesse Login Utente
/
class UtenteLogoutHandler extends LogoutHandler
{
/*-
Metodo gestione Logout Utente
-
Setter
-
@param array $dati Dati form login
-
@param object $form Form login
-
@return HTTPResponse
*/
public function doLogOut($utente)
{
// Controllo Utente
if ($utente) {
$request = Injector::inst()->get(HTTPRequest::class);
$session = $request->getSession();
$paziente = $session->get(‘UtenteLoginHandler.MemberID’);
$datiPaziente = $session->get(‘UtenteLoginHandler.Data’);// Controllo Sessione Utente if ($paziente && $datiPaziente) { $session->clear('UtenteLoginHandler.MemberID'); $session->clear('UtenteLoginHandler.Data'); Security::setCurrentUser(null); return $this->redirectAfterLogout(); // I tried with this approach too without success.. /* if ($utente instanceof Member) { Injector::inst()->get(IdentityStore::class)->logOut($this->getRequest()); return $this->redirectAfterLogout(); } */ } else { // Se utente invalido torna al form return $this->redirectBack(); }
} else {
// Se sessione utente invalida torna al form
return $this->redirectBack();
}
}
}[/code]
-
A little help to solve this issue it will be very appreciated.
Thanks in advance everyone.
P.S. I reported this to Stack Overflow too. For more information read here