Module: Sinatra::Authorization
- Defined in:
- lib/authorization.rb
Instance Method Summary collapse
Instance Method Details
#authorize!(username, password) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/authorization.rb', line 4 def (username, password) # get the only instance of the Config class config_data = ConfigInfo.instance if (username == config_data.username) && (password == config_data.password) session[:authorized] = true true else session[:authorized] = false false end end |
#is_authorized? ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/authorization.rb', line 18 def if session[:authorized] true else false end end |
#requires_login! ⇒ Object
26 27 28 29 30 |
# File 'lib/authorization.rb', line 26 def requires_login! if ! redirect '/login' end end |