Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Authenticator::set_default_authenticator problem

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2600 Views
  • Entar
    Avatar
    Community Member
    19 Posts

    Authenticator::set_default_authenticator problem Link to this post

    hey all!

    I have a little problem with authenticators. I'm trying to change default authenticator, plus remove all other (in my case it's just MemberAuthenticator). Code in my _config.php:

    Authenticator::register_authenticator('ExtendedAuthenticator');
    Authenticator::set_default_authenticator('ExtendedAuthenticator'); // seems not work at all
    Authenticator::unregister_authenticator('MemberAuthenticator');

    it works well, I'm going to /Security/login/ to test my authenticator and it seems something go wrong from this point:

    [User Error] Passed invalid authentication method
    POST /Security/LoginForm
    Line 215 in C:\Server\httpd\web\sapphire\security\Security.php
    Source

    206       if(isset($this->requestParams['AuthenticationMethod'])) {
    207          $authenticator = trim($_REQUEST['AuthenticationMethod']);
    208
    209          $authenticators = Authenticator::get_authenticators();
    210          if(in_array($authenticator, $authenticators)) {
    211             return call_user_func(array($authenticator, 'get_login_form'), $this);
    212          }
    213       }
    214
    215       user_error('Passed invalid authentication method', E_USER_ERROR);
    216    }
    217
    218
    219 /**
    220     * Get the login forms for all available authentication methods
    221     *

    Trace

    * Passed invalid authentication method
    Line 215 of Security.php
    * Security->LoginForm(HTTPRequest)
    Line 162 of Controller.php
    * Controller->handleAction(HTTPRequest)
    Line 107 of RequestHandler.php
    * RequestHandler->handleRequest(HTTPRequest)
    Line 122 of Controller.php
    * Controller->handleRequest(HTTPRequest)
    Line 262 of Director.php
    * Director::handleRequest(HTTPRequest,Session)
    Line 106 of Director.php
    * Director::direct(/Security/LoginForm)
    Line 115 of main.php

    Is there any way to change authentication class not getting this errors? My main task is to add new conditions to login, like is user activated or not check. I've already added necessary things to db, so this check is last one... Thanks!

  • Entar
    Avatar
    Community Member
    19 Posts
  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Authenticator::set_default_authenticator problem Link to this post

    Wow, this is a 4 year old post I am bumping, I think that is a first!

    I am having a similar problem, I have a custom authenticator, loaded exactly as @Entar describes.

    I have a login widget that loads the new authenticator and I can login using that, but if I try to use the login form, it causes this error?

    I get the impression I am missing a step?

    Cheers,

    Mo

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Authenticator::set_default_authenticator problem Link to this post

    Right, I found a solution for this, hopefully it will help anyone else with this issue.

    My problem was that on my custom authentication form, I had set the param $authenticator_class wrong. The param needs to be set to:

    class CustomLoginForm extends MemberLoginForm {
    ...

    protected $authenticator_class = "MyAuthenticationClass";

    ...
    }

    Hope that helps someone else who gets stuck on this.

    Mo

    2600 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.