Module: Mumukit::Platform::WebFramework::Sinatra
- Defined in:
- lib/mumukit/login/framework/sinatra.rb
Class Method Summary collapse
- .configure_controller!(sinatra_helpers) ⇒ Object
- .configure_login_controller!(sinatra_helpers) ⇒ Object
- .configure_login_routes!(sinatra_module) ⇒ Object
- .delete_cookie!(key, domain, sinatra_handler) ⇒ Object
- .env(sinatra_handler) ⇒ Object
- .read_cookie(key, sinatra_handler) ⇒ Object
- .redirect!(path, sinatra_handler) ⇒ Object
- .render_html!(html, sinatra_handler) ⇒ Object
- .write_cookie!(key, value, sinatra_handler) ⇒ Object
Class Method Details
.configure_controller!(sinatra_helpers) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 49 def self.configure_controller!(sinatra_helpers) sinatra_helpers.instance_eval do include Mumukit::Login::AuthenticationHelpers include Mumukit::Login::AuthorizationHelpers end end |
.configure_login_controller!(sinatra_helpers) ⇒ Object
43 44 45 46 47 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 43 def self.configure_login_controller!(sinatra_helpers) sinatra_helpers.instance_eval do include Mumukit::Login::LoginControllerHelpers end end |
.configure_login_routes!(sinatra_module) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 31 def self.configure_login_routes!(sinatra_module) sinatra_module.instance_eval do auth_callback = proc { callback_current_user! } get '/auth/:provider/callback', &auth_callback post '/auth/:provider/callback', &auth_callback get('/auth/failure') { login_failure! } get('/logout') { logout_current_user! } get('/login') { login_current_user! } end end |
.delete_cookie!(key, domain, sinatra_handler) ⇒ Object
10 11 12 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 10 def self.(key, domain, sinatra_handler) sinatra_handler.response. key, domain: domain end |
.env(sinatra_handler) ⇒ Object
2 3 4 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 2 def self.env(sinatra_handler) sinatra_handler.request.env end |
.read_cookie(key, sinatra_handler) ⇒ Object
14 15 16 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 14 def self.(key, sinatra_handler) sinatra_handler.request.[key] end |
.redirect!(path, sinatra_handler) ⇒ Object
18 19 20 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 18 def self.redirect!(path, sinatra_handler) sinatra_handler.redirect path end |
.render_html!(html, sinatra_handler) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 22 def self.render_html!(html, sinatra_handler) <<HTML <html> <head>#{html[:header]}</head> <body>#{html[:body]}</body> </html> HTML end |
.write_cookie!(key, value, sinatra_handler) ⇒ Object
6 7 8 |
# File 'lib/mumukit/login/framework/sinatra.rb', line 6 def self.(key, value, sinatra_handler) sinatra_handler.response. key, value end |