Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Authenticator::set_default_authenticator problem


Go to End


4 Posts   3983 Views

Avatar
Entar

Community Member, 23 Posts

5 March 2009 at 10:44am

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!

Avatar
Entar

Community Member, 23 Posts

9 March 2009 at 11:33pm

anyone?

Avatar
Mo

Community Member, 541 Posts

15 November 2013 at 4:02am

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

Avatar
Mo

Community Member, 541 Posts

15 November 2013 at 4:17am

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