5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 994 Views |
-
login form

24 June 2011 at 6:06pm
hi, im new to SilverStripe... im glad to know this cms.
its still hard to me to customize this cms. i would like add new field to user login form (for example captcha). i do not know where to go... -
Re: login form

25 June 2011 at 4:06am
Hi trustnoone!
Welcome to SS.
The most simple way to do this is to extend MemberAuthenticator, create a new class such as MyMemberAuthenticator and create a static function called get_login_form that accepts 1 parameter ($controller). then return a new form with the fields you want. They will need to have the same names for the username and password.
You then have to register that authenticator in your _config and unregister the existing one. So in the end you want something like this:
MyMemberAuthenticator.php:
class MyMemberAuthentcator extends MemberAuthenticator {
public static function get_login_form(Controller $controller) {
$label=singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
$fields = new FieldSet(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
//Regardless of what the unique identifer field is (usually 'Email'), it will be held in the 'Email' value, below:
new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
);
if(Security::$autologin_enabled) {
$fields->push(new CheckboxField(
"Remember",
_t('Member.REMEMBERME', "Remember me next time?")
));
}
//push your custom fields in here
$fields->push( ... )
return new MemberLoginForm($controller, 'MemberLoginForm',$fields);
}
}_config.php
Authenticator::unregister_authenticator('MemberAuthenticator');
Authenticator::register_authenticator('MyMemberAuthenticator');And that should be the ground work done. Validation may be the only problem here, but you can just extend the authenticate method if you need to.
Enjoy!
-
Re: login form

27 June 2011 at 1:29pm
thanks for the reply...
sorry for the late respond. i didn't tried your method yet, yesterday i tried extend MemberLoginForm class. and the functionality is running as i want. when the user tried to login 3 times (wrong login), the MathSpamProtection will show. and the validation i did in dologin function.
i still trying to notice, what is the different with your method...
-
Re: login form

2 June 2012 at 2:19am
I found this http://tamethebackbutton.blogspot.co.uk/2009/09/customize-your-own-silverstripe-login.html
If you need only to change the template, you need to put Security_login.ss in your templates/Layout folder under your theme
| 994 Views | ||
|
Page:
1
|
Go to Top |



