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.

General Questions /

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

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

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


Go to End


13 Posts   3841 Views

Avatar
Willr

Forum Moderator, 5523 Posts

18 August 2010 at 9:12am

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

Forum Moderator, 5523 Posts

18 August 2010 at 9:12am

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

Community Member, 56 Posts

18 August 2010 at 5:57pm

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

Community Member, 56 Posts

18 August 2010 at 5:57pm

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

Avatar
Ryan M.

Community Member, 309 Posts

11 September 2010 at 1:02am

Edited: 11/09/2010 1:03am

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.

Go to Top