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.

General Questions

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

Executing a class method from the URL (for logout method)


Reply

13 Posts   2300 Views

Avatar
Willr

18 August 2010 at 9:12am Forum Moderator, 5511 Posts

AFAIK custer, Decorators won't work in this sense for controllers. I don't believe it is setup to check whether functions exist on the extensions. I ran into trouble with this myself. Haven't dug much deeper into it.

Avatar
Willr

18 August 2010 at 9:12am Forum Moderator, 5511 Posts

AFAIK custer, Decorators won't work in this sense for controllers. I don't believe it is setup to check whether functions exist on the extensions. I ran into trouble with this myself. Haven't dug much deeper into it.

Avatar
cuSSter

18 August 2010 at 5:57pm Community Member, 56 Posts

So for this issue, the only workaround is to hack the core and add the function that you post and add that function in the $allowed_actions? Thanks by the way for the quick response. :)

Avatar
cuSSter

18 August 2010 at 5:57pm Community Member, 56 Posts

By the way, I'm working on the 2.4.0 version of SilverStripe.

Avatar
Ryan M.

11 September 2010 at 1:02am (Last edited: 11 September 2010 1:03am), Community Member, 309 Posts

I'd like to add to this thread, because I was looking for a similar logout solution, since the ?BackURL doesn't work on Security/logout.

My problem was that I needed the logout action to work anywhere and I didn't want to hard-code it into the template because the base href will direct it to domain.com/logout instead of domain.com/page/logout. Ergo, my solution was:

in Page.php -> Page_Controller

public function LogoutLink() {
      return $this->Link('logout');
   }
   
   function logout() {
      if($mem = Member::currentUser()) {
         $mem->logOut();
      }
      return Director::redirect("home/");
   }

Simply insert $LogoutLink anywhere you have a logout link on your site. It'll log the user out no matter what page they were on.