Jump to:

23487 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Custom Login Form

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 783 Views
  • Liam
    Avatar
    Community Member
    470 Posts

    Custom Login Form Link to this post

    I extended MemberLoginForm similar to like the old SSbits tutorial for client redirection http://www.ssbits.com/tutorials/2009/custom-login-form-with-group-based-redirection/

    But is it possible to have 2 login forms, instead of overriding? The reason being, I want 1 form for admin logins, and the custom form for the client redirection since they will never need CMS access. I realize the SSbits tutorial takes it into account, but I'd rather keep it simple since none of the client logins will need access and I"m curious for my own knowledge. If not, I can just do it similar to how SSBits handles it.

    Ideally I want to create a client login page and put the custom form on it. Is there a way to attach the extended form to my pagetype and have a variable like $CustomLoginForm in my template? Something like that.

    CustomLoginForm.php

    <?php
    class CustomLoginForm extends MemberLoginForm {
    public function dologin($data) {
    if($this->performLogin($data)) {
    if(!$this->redirectByClient($data))
    Controller::curr()->redirect(Director::baseURL());
    } else {
    if($badLoginURL = Session::get('BadLoginURL')) {
    Controller::curr()->redirect($badLoginURL);
    } else {
    Controller::curr()->redirectBack();
    }
    }
    }

    public function redirectByClient($data) {
    $member = Member::currentUser();

    if ($member && $Page = $member->ClientPage()) {
    return Controller::curr()->redirect($Page->Link());
    }

    return false;
    }
    }

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Custom Login Form Link to this post

    Hi Liam,

    I know this doesn't answer your question directly but maybe it helps - I noticed this new module that handles this for admin forms in SS3 - https://github.com/axyr/silverstripe-adminlogin

    Barry

    783 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.