I’m missing something obvious about extensions and authentication
requirements?
Background
I setup an extension hoping to be able to process forms from the
public side
of the site.
-
using Mental Branch
-
run ruby script\generate extension mailertest
-
update mailertest_extension.rb:
define_routes do |map|
map.connect ‘mailertest/:action’, :controller => ‘mailertest’
end
-
in mailertest controller add method to make sure the new controller is
used:
def index
logger.info(“if I’m not back in 5 minutes, wait longer”)
end
-
access http://localhost:3000/mailertest
where I’m promptly redirected to the /admin/ login screen.
log:
Redirected to http://localhost:3000/admin/login
Filter chain halted as
[#<ActionController::Filters::ClassMethods::SymbolFilter:0x950b85c
@filter=:authenticate>] returned false.
Filter chain halted as [:authenticate] did not yield.
–/–
I’m missing something obvious aren’t I? Is there a way to specify that
an
extension shouldn’t require authentication?
Actually, maybe I’m on the wrong track all together - I want to be able
to
process forms submitted from the public side of the site. I don’t need
any
tags that will create the forms and inputs. Perhaps, easier if I add a
route
in routes.rb to /mailertest and put the controller alongside Radiant
code?
Any insight appreciated!
Todd M
Hey Todd,
Add “no_login_required” after the class declaration.
Your buddy,
Todd
Quoting Todd McGrath [email protected]:
Todd,
Thanks for this, I had already given-up on the possibility of an
extension doing anything other than packaging-up an admin interface
for functionality which would have to happen through Radius tags. As
it is this is much more powerful, especially if I can figure-out how
to flow the output of my views into a Radiant layout.
However, when I apply the technique you describe I still get sent to
the login screen. What am I doing wrong in-order to bypass the admin
login requirement. Here is my Radiant::Extension class declaration
including the “no_login_required” flag:
class StaffListingExtension < Radiant::Extension
version “1.0”
description “An extension for a staff listing”
url “http://fn-group.com”
no_login_required
define_routes do |map|
# map.connect ‘admin/staff_listing/:action’, :controller => ‘staff’
map.connect ‘directory/:action’, :controller => ‘staff’
end
def activate
# admin.tabs.add “Staff Listing”, “/admin/staff_listing”, :after
=> “Layouts”, :visibility => [:all]
end
def deactivate
# admin.tabs.remove “Staff Listing”
end
end
?
Thanks,
Loren J.
Hi Loren,
Looking back, I wasn’t very clear. I was too busy laughing for sending
an email
to myself. Should have said “add it to your controller”; i.e.
class TellafriendController < ApplicationController
no_login_required
def sendafriend
render :update do |page|
page.replace_html(“target”, “Mail sent”)
page[:target].visual_effect :highlight,
:startcolor => “#88ff88”,
:endcolor => “#114411”
end
end
end
As you can see, I just want to be able to respond to AJAX requests.
Based on your post, you need to add “no_login_required” to your
directory
controller.
Hope this helps and please post back to the list your experiences with
view
output.
Todd McGrath
Quoting Loren J. [email protected]: