Module: Scat::Authorization
- Includes:
- Sinatra::Authorization
- Defined in:
- lib/scat/authorization.rb
Instance Method Summary collapse
-
#authorization_realm ⇒ Object
Fix
Sinatra::Authorization.authorization_realm
per the (github.com/sr/sinatra-authorization)[https://github.com/sr/sinatra-authorization] patch. -
#current_user ⇒ CaTissue::User
The user who is submitting this edit.
-
#protect! { ... } ⇒ Object
Runs the given block in an HTTP basic authorization context.
Instance Method Details
#authorization_realm ⇒ Object
Fix Sinatra::Authorization.authorization_realm
per the (github.com/sr/sinatra-authorization)[https://github.com/sr/sinatra-authorization] patch.
38 39 40 |
# File 'lib/scat/authorization.rb', line 38 def settings. end |
#current_user ⇒ CaTissue::User
Returns the user who is submitting this edit.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/scat/authorization.rb', line 17 def current_user # The caTissue login name is the user's email address. email = session[:email] raise ScatError.new("The caTissue login is not available in this web session.") unless email # the current caTissue User user = CaTissue::User.new(:email_address => email) # the cached caTissue User id user_id = session[:user_id] if user_id then user.identifier = user_id else # Fetch the User and cache the id. raise ScatError.new("User not found: #{user.email_address}") unless user.find session[:user_id] = user.identifier end user end |
#protect! { ... } ⇒ Object
Runs the given block in an HTTP basic authorization context. The session status is set to the result of performing the given block.
10 11 12 13 |
# File 'lib/scat/authorization.rb', line 10 def protect!(&block) login_required session[:status] = perform!(session[:email], session[:password], &block) end |