module Sinatra::Authentication::Helpers

Public Instance Methods

__USER__() click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 34
def __USER__
    settings.login_user_class
end
authenticate(opts) click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 28
def authenticate(opts)
    if user = __USER__.authenticate(opts[:email], opts[:password])
        user.id
    end
end
current_user(finder = lambda { |id| __USER__[id] }) click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 8
def current_user(finder = lambda { |id| __USER__[id] })
    # Replace this with OttomanORM shit
    # NOTE: not keeping session data
    # @current_user ||= finder.call(session[:user]) if session[:user]
    nil
end
ensure_current_user(user) click to toggle source

def logged_in?

!!curent_user

end

# File lib/sinatra/authentication/helpers.rb, line 19
def ensure_current_user(user)
    halt 404 unless user == current_user
end
logout!() click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 23
def logout!
    # NOTE: not keeping session data
    # session.delete(:user)
end
require_auth(cookies, required_roles = []) click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 4
def require_auth cookies, required_roles = []
    __USER__.user_auth(cookies, required_roles)
end
should_return_to?(path, ignored = settings.ignored_by_return_to) click to toggle source
# File lib/sinatra/authentication/helpers.rb, line 38
def should_return_to?(path, ignored = settings.ignored_by_return_to)
    !(path =~ ignored)
end