Guest User

Untitled

a guest
Jun 3rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. # Default url mappings are:
  2. # a controller called Main is mapped on the root of the site: /
  3. # a controller called Something is mapped on: /something
  4. # If you want to override this, add a line like this inside the class
  5. # map '/otherurl'
  6. # this will force the controller to be mounted on: /otherurl
  7.  
  8. class BryceController < Controller
  9. # the index action is called automatically when no other action is specified
  10. helper :auth
  11.  
  12. def index
  13. @title = "Welcome to My Site!"
  14. puts @title
  15. end
  16.  
  17. before(:names) { login }
  18. def names
  19. @title = "Hello Protected Page"
  20. end
  21.  
  22. def login
  23. flash[:error] = 'login required to view that page' unless logged_in?
  24. super
  25. end
  26.  
  27. def check_auth user, pass
  28. return false if (not user or user.empty?) and (not pass or pass.empty?)
  29. if User[:username => user, :password => pass].nil?
  30. flash[:error] = 'invalid username or password'
  31. false
  32. else
  33. true
  34. end
  35. end
  36.  
  37.  
  38. # the string returned at the end of the function is used as the html body
  39. # if there is no template for the action. if there is a template, the string
  40. # is silently ignored
  41. def notemplate
  42. "there is no 'notemplate.xhtml' associated with this action"
  43. end
  44. end
Add Comment
Please, Sign In to add comment