Module: Sinatra::Security
- Defined in:
- lib/sinatra/security.rb,
lib/sinatra/security/user.rb,
lib/sinatra/security/helpers.rb,
lib/sinatra/security/password.rb,
lib/sinatra/security/login_field.rb,
lib/sinatra/security/validations.rb,
lib/sinatra/security/identification.rb
Defined Under Namespace
Modules: Helpers, Identification, LoginField, Password, User, Validations
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
Instance Method Summary collapse
-
#require_login(path_prefix) ⇒ nil
Allows you to declaratively declare secured locations based on their path prefix.
Class Method Details
.registered(app) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sinatra/security.rb', line 14 def self.registered(app) app.helpers Helpers app.set :login_error_message, "Wrong Email and/or Password combination." app.set :login_url, "/login" app.set :login_user_class, lambda { ::User } app.set :ignored_by_return_to, /(jpe?g|png|gif|css|js)$/ app.post '/login' do if authenticate(params) redirect_to_return_url else session[:error] = settings. redirect settings.login_url end end end |
Instance Method Details
#require_login(path_prefix) ⇒ nil
Allows you to declaratively declare secured locations based on their path prefix.
50 51 52 53 54 55 56 |
# File 'lib/sinatra/security.rb', line 50 def require_login(path_prefix) before do if request.fullpath =~ /^#{path_prefix}/ require_login end end end |