Skip to content
Browse files

Remove user stuff.

This... isn't needed. There are no users.
  • Loading branch information...
1 parent 6dd79b8 commit 4164a395b5447cd4c033641862b8eb85eae115f0 @steveklabnik committed Feb 24, 2013
Showing with 1 addition and 88 deletions.
  1. +1 −1 Gemfile.lock
  2. +0 −20 blog.rb
  3. +0 −28 user.rb
  4. +0 −39 warden.rb
View
2 Gemfile.lock
@@ -1,5 +1,5 @@
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
addressable (2.2.6)
backports (2.6.3)
View
20 blog.rb
@@ -3,21 +3,11 @@
require 'sinatra/content_for'
-require_relative "user"
-require_relative "warden"
require_relative "source_file"
require_relative "redirects"
class Blog < Sinatra::Base
- use Rack::Session::Cookie, :secret => ENV['SESSION_SECRET']
- use Warden::Manager do |manager|
- manager.default_strategies :password
- manager.failure_app = Blog
- end
-
- helpers WardenHelpers
helpers Sinatra::ContentFor
- use Rack::Flash
helpers do
def title
@@ -73,16 +63,6 @@ def format_outline(outline)
rss.to_s
end
- get '/signup' do
- haml :signup, :layout => :full_page_layout
- end
-
- post '/signup' do
- User.create(params[:user])
- flash[:notice] = "All signed up! Thanks!"
- redirect '/'
- end
-
get '/posts/:id' do
begin
source = SourceFile.new(params[:id])
View
28 user.rb
@@ -1,28 +0,0 @@
-require 'bcrypt'
-
-DataMapper.setup(:default, ENV['DATABASE_URL'] || {:adapter => 'sqlite3', :database => 'db/development.sqlite3'})
-
-class User
- include DataMapper::Resource
-
- property :id, Serial
- property :email, String
- property :encrypted_password, String
-
- attr_accessor :password
-
- before :create do |user|
- user.encrypted_password = BCrypt::Password.create(user.password, :cost => 5)
- end
-
- def self.authenticate(email, password)
- u = first(:email => email)
- return nil if u.nil?
- return nil unless u.encrypted_password = BCrypt::Password.create(password, :cost => 5)
- u
- end
-end
-
-DataMapper.finalize
-DataMapper.auto_upgrade!
-
View
39 warden.rb
@@ -1,39 +0,0 @@
-Warden::Manager.serialize_into_session{|user| user.id }
-Warden::Manager.serialize_from_session{|id| User.get(id) }
-
-Warden::Manager.before_failure do |env,opts|
- env['REQUEST_METHOD'] = "POST"
-end
-
-Warden::Strategies.add(:password) do
- def valid?
- params["user"]["email"] || params["user"]["password"]
- end
-
- def authenticate!
- u = User.authenticate(params["user"]["email"], params["user"]["password"])
- u.nil? ? fail!("Could not log in") : success!(u)
- end
-end
-
-module WardenHelpers
- def warden
- env['warden']
- end
-
- def current_user
- warden.user
- end
-
- def logged_in?
- !current_user.nil?
- end
-
- def authenticate!
- warden.authenticate!
- end
-
- def log_out!
- warden.logout
- end
-end

0 comments on commit 4164a39

Please sign in to comment.
Something went wrong with that request. Please try again.