21278 Posts in 5728 Topics by 2599 members
General Questions
SilverStripe Forums » General Questions » Executing a class method from the URL (for logout method)
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1610 Views |
-
Re: Executing a class method from the URL (for logout method)

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.
-
Re: Executing a class method from the URL (for logout method)

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.
-
Re: Executing a class method from the URL (for logout method)

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.
-
Re: Executing a class method from the URL (for logout method)

18 August 2010 at 5:57pm
By the way, I'm working on the 2.4.0 version of SilverStripe.
-
Re: Executing a class method from the URL (for logout method)

11 September 2010 at 1:02am Last edited: 11 September 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.
| 1610 Views | ||
| Go to Top |



