Sha256: 61df2773b88e7851d002b2b3a8dd020e622a5927396cb3acbd57f188c0bceceb

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

module Sinatra
  module Authorization

    def authorize!(username, password)
      # get the only instance of the Config class
      config_data = ConfigInfo.instance

      if (username == config_data.username) && (password == config_data.password)
        session[:authorized] = true
        true
      else
        session[:authorized] = false
        false
      end

    end

    def is_authorized?
      if session[:authorized]
        true
      else
        false
      end
    end

    def requires_login!
      if !is_authorized?
        redirect '/login'
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shagit-0.3.1 lib/authorization.rb
shagit-0.3.0 lib/authorization.rb