Sha256: 313669e31083668d3d474ad166c04fc871b95f362ef71ff1b06704e3a750c12a

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

module SessionHelper  
  helpers do
    
    # Check credentials against config file
    def authenticate( creds )
      env = Sinatra::Application.environment.to_s
      config = YAML.load_file( default_config )
      conf  = config[env]      
      ((creds['username'] == conf['auth']['user']) and (creds['password'] == conf['auth']['password']))
    end
    
    def console_auth?
      env = Sinatra::Application.environment.to_s
      config = YAML.load_file( default_config )
      conf  = config[env]
      conf['auth']
    end
    
    # Check if session has auth
    def authenticated?
      session[:user]
    end
    
    # check for login path
    def root_path?
      request.path == "/"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wackamole-0.0.9 lib/helpers/session_helper.rb