Silverstripe 4-找不到身份验证器类 [英] Silverstripe 4 - Authenticator class not found
问题描述
我将允许默认用户从默认的from SilverStripe 4网站前端页面注销.由于登录有效而注销.
I would allow pre-generated users to log out from a SilverStripe 4 website front-end page, by using the default from. Logging out because log in works.
问题是,如果登录的一般用户尝试通过单击诸如Security/logout
(以及Security/logout?BackURL=home/
)之类的链接注销,则该用户将被重定向到空白页(仅显示页眉/页脚,如下所示)默认的Page.ss
已实现).显然,该控制器无法正常工作或类似,因为URL仅将我指向Security/logout
,而没有后续重定向.
The problem is that if a logged generic user tries to log out by clicking on a link like Security/logout
(as well as Security/logout?BackURL=home/
), it being redirected to a blank page (just with header/footer visible, as the default Page.ss
is implemented). Apparently the controller doesn't work or similar, because URL points me simply to Security/logout
with no following redirects.
因此,我尝试实现自定义身份验证器,就像我在SS 3中通常所做的那样,但是我注意到了一些小差异.然后,我同时遵循了官方文档和建议的示例以寻求帮助.
So, I tried to implement a custom authenticator, as I usually do in SS 3, but I noticed some little differences. Then, I followed both the official doc and the suggested example for help.
这种情况:
MemberAuthenticator自定义类 (在 MySite/code 中)
<?php
// Definizione Namespace
namespace Greylab\Corporate\Authenticator\UtenteAuthenticator;
use SilverStripe\Security\MemberAuthenticator\Authenticator;
/**
* Classe Autenticazione Utente
*/
class UtenteAuthenticator extends Authenticator
{
/**
* Login Paziente - Getter
* @param string $link URL di autenteicazione utente
* @return object Form di autenticazione utente
*/
public function getLoginHandler($link)
{
return UtenteLoginHandler::create($link, $this);
}
}
MemberAuthenticator \ LoginHandler自定义类 (在 MySite/code 中)
<?php
// Definizione Namespace
use SilverStripe\Security\MemberAuthenticator\LoginHandler;
use SilverStripe\Control\Session;
/**
* Clesse Login Utente
*/
class UtenteLoginHandler extends LoginHandler
{
/**
* Metodo gestione Login Utente
* Setter
* @param array $dati Dati form login
* @param object $form Form login
* @return void
*/
public function doLogin($dati, $form)
{
$utente = $this->checkLogin($dati);
// Controllo Utente
if ($utente) {
$cliente = Session::set('UtenteLoginHandler.MemberID', $utente->ID);
$datiCliente = Session::set('UtenteLoginHandler.Data', $dati);
$this->performLogin($cliente, $datiCliente);
return $this->redirectAfterSuccessfulLogin();
} else {
// Se utente invalido torna al form
return $this->redirectBack();
}
}
}
MemberAuthenticator \ LoginHandler自定义类 (在_MySite/ config/mysite.yml 中)
MemberAuthenticator\LoginHandler custom class (in _MySite/config/mysite.yml)
SilverStripe\Core\Injector\Injector:
SilverStripe\Security\Security:
properties:
Authenticators:
UtenteAuthenticator: %$Greylab\Corporate\Authenticator\UtenteAuthenticator
通过此实现,系统会向我抛出此异常:
With this implementation the system throw me this exception:
PHP致命错误:在第10行的/Applications/MAMP/htdocs/corporate/ss_corporate/corporate/code/UtenteAuthenticator.php中找不到类'SilverStripe \ Security \ MemberAuthenticator \ Authenticator'
PHP Fatal error: Class 'SilverStripe\Security\MemberAuthenticator\Authenticator' not found in /Applications/MAMP/htdocs/corporate/ss_corporate/corporate/code/UtenteAuthenticator.php on line 10
有人可以建议我正确的方法吗?
Anyone can suggest me the right way?
提前感谢大家.
推荐答案
您可能需要使用
use SilverStripe\Security\MemberAuthenticator\CMSMemberAuthenticator
查看文档: http://api.silverstripe.org/4/SilverStripe/Security/MemberAuthenticator. html
这篇关于Silverstripe 4-找不到身份验证器类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!