Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Default url mappings are:
- # a controller called Main is mapped on the root of the site: /
- # a controller called Something is mapped on: /something
- # If you want to override this, add a line like this inside the class
- # map '/otherurl'
- # this will force the controller to be mounted on: /otherurl
- class BryceController < Controller
- # the index action is called automatically when no other action is specified
- helper :auth
- def index
- @title = "Welcome to My Site!"
- puts @title
- end
- before(:names) { login }
- def names
- @title = "Hello Protected Page"
- end
- def login
- flash[:error] = 'login required to view that page' unless logged_in?
- super
- end
- def check_auth user, pass
- return false if (not user or user.empty?) and (not pass or pass.empty?)
- if User[:username => user, :password => pass].nil?
- flash[:error] = 'invalid username or password'
- false
- else
- true
- end
- end
- # the string returned at the end of the function is used as the html body
- # if there is no template for the action. if there is a template, the string
- # is silently ignored
- def notemplate
- "there is no 'notemplate.xhtml' associated with this action"
- end
- end
Add Comment
Please, Sign In to add comment