Sha256: 828ebca139031bcbf1d65d07b243d877213b24600a7884af9edcb3f34aa5dfcf
Contents?: true
Size: 940 Bytes
Versions: 1
Compression:
Stored size: 940 Bytes
Contents
require 'rubygems' require 'sequel/sqlite' DB = Sequel.sqlite class User < Sequel::Model(:users) set_schema do primary_key :id varchar :username varchar :password end end unless User.table_exists? User.create_table User.create :username => 'admin', :password => 'passwort' end require 'ramaze' class MainController < Ramaze::Controller helper :auth layout :layout before(:index) { login_required } def index "Hello #{session[:username]}" end private def login_required flash[:error] = 'login required to view that page' unless logged_in? super end def check_auth user, pass return false if (not user or user.empty?) and (not pass or pass.empty?) if User[:username => user, :password => pass].nil? flash[:error] = 'invalid username or password' false else true end end end Ramaze.start :adapter => :mongrel, :load_engines => :Haml
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.2.0 | examples/auth/auth.rb |