Removed "authlogic" completely. Let's try "devise".

This commit is contained in:
Christoph Haas 2015-07-15 17:05:56 +02:00
parent 4b4cbf4b88
commit e6a0f15340
26 changed files with 10 additions and 260 deletions

View file

@ -104,4 +104,3 @@ gem 'cookies_eu'
gem 'bzip2-ruby', :git => 'https://github.com/chewi/bzip2-ruby.git' gem 'bzip2-ruby', :git => 'https://github.com/chewi/bzip2-ruby.git'
# Authentication # Authentication
gem 'authlogic'

View file

@ -43,11 +43,6 @@ GEM
thread_safe (~> 0.3, >= 0.3.4) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
arel (6.0.0) arel (6.0.0)
authlogic (3.4.5)
activerecord (>= 3.2)
activesupport (>= 3.2)
request_store (~> 1.0)
scrypt (~> 1.2)
better_errors (2.1.1) better_errors (2.1.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubis (>= 2.6.6) erubis (>= 2.6.6)

View file

@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -1,3 +0,0 @@
// Place all the styles related to the user_sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -1,3 +0,0 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -8,56 +8,10 @@ class ApplicationController < ActionController::Base
# Do not mention passwords in the log file # Do not mention passwords in the log file
# filter_parameter_logging :password # filter_parameter_logging :password
# AuthLogic
helper_method :current_user_session, :current_user
# Assign the visitor a unique hash so that we can track their uploads # Assign the visitor a unique hash so that we can track their uploads
# and show them even before moderation. # and show them even before moderation.
def create_user_token def create_user_token
session[:token] ||= SecureRandom.hex session[:token] ||= SecureRandom.hex
session[:ip] ||= request.remote_ip session[:ip] ||= request.remote_ip
end end
# -----------------
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
def require_user
logger.debug "ApplicationController::require_user"
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
logger.debug "ApplicationController::require_no_user"
if current_user
store_location
flash[:notice] = "You must be logged out to access this page"
# redirect_to home_index_path
return false
end
end
def store_location
#session[:return_to] = request.request_uri
end
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end
end end

View file

@ -1,26 +0,0 @@
class UserSessionsController < ApplicationController
# before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_back_or_default account_url(@current_user)
else
render :action => :new
end
end
def destroy
if current_user
current_user_session.destroy
flash[:notice] = "Logout successful!"
end
redirect_back_or_default new_user_session_url
end
end

View file

@ -1,43 +0,0 @@
class UsersController < ApplicationController
before_filter :require_user, :only => [:show, :edit, :update]
def new
@user = User.new
end
def create
@user = User.new(params[:user])
# Saving without session maintenance to skip
# auto-login which can't happen here because
# the User has not yet been activated
if @user.save
flash[:notice] = "Your account has been created."
redirect_to signup_url
else
flash[:notice] = "There was a problem creating you."
render :action => :new
end
end
def show
@user = current_user
end
def edit
@user = current_user
end
def update
@user = current_user # makes our views "cleaner" and more consistent
if @user.update_attributes(params[:user])
flash[:notice] = "Account updated!"
redirect_to account_url
else
render :action => :edit
end
end
end

View file

@ -1,2 +0,0 @@
module UserSessionsHelper
end

View file

@ -1,2 +0,0 @@
module UsersHelper
end

View file

@ -1,5 +1,2 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
acts_as_authentic do |c|
c.login_field = 'email'
end
end end

View file

@ -1,7 +0,0 @@
# User sessions. Refers to the "User" class automatically (by its name).
# See also: https://github.com/binarylogic/authlogic
class UserSession < Authlogic::Session::Base
# specify configuration here, such as:
# logout_on_timeout true
# ...many more options in the documentation
end

View file

@ -1,6 +0,0 @@
- if target.errors.any?
div id="errorExplanation"
h2 Errors
ul
- target.errors.full_messages.each do |msg|
li = msg

View file

@ -1,12 +0,0 @@
h1 Login
= form_for @user_session, :as => :user_session, :url => { :action => "create" } do |f|
= render "shared/error_messages", :target => @user_session
= f.label :email
br
= f.text_field :email
br
= f.label :password
br
= f.password_field :password
br
= f.submit "Login"

View file

@ -1,20 +0,0 @@
= render "shared/error_messages", :target => @user
p
= form.label :realname
br
= form.text_field :realname
p
= form.label :email
br
= form.text_field :email
p
= form.label :password, form.object.new_record? ? nil : "Change password"
br
= form.password_field :password
p
= form.label :password_confirmation
br
= form.password_field :password_confirmation
= link_to 'Edit Account', edit_account_path

View file

@ -1,5 +0,0 @@
h1 Register
= form_for @user do |f|
= render :partial => "form", :object => f, :locals => { :user => @user }
= f.submit "Register"

View file

@ -1,28 +0,0 @@
p
b Email:
=h @user.email
p
b Login count:
=h @user.login_count
p
b Last request at:
=h @user.last_request_at
p
b Last login at:
=h @user.last_login_at
p
b Current login at:
=h @user.current_login_at
p
b Last login ip:
=h @user.last_login_ip
p
b Current login ip:
=h @user.current_login_ip

View file

@ -21,18 +21,6 @@ Debshots::Application.routes.draw do
get 'about' => 'welcome#about' get 'about' => 'welcome#about'
get 'thumbnail/:name' => 'packages#thumbnail', as: :thumbnail_image, name: /[^\/]+/ get 'thumbnail/:name' => 'packages#thumbnail', as: :thumbnail_image, name: /[^\/]+/
# Authentication
resources :user_sessions
get 'login' => "user_sessions#new", :as => :login
get 'logout' => "user_sessions#destroy", :as => :logout
resources :users # give us our some normal resource routes for users
resource :user, :as => 'account' # a convenience route
#match 'signup' => 'users#new', :as => :signup
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".

View file

@ -0,0 +1,5 @@
class DropUserSessionsTable < ActiveRecord::Migration
def change
drop_table :user_sessions
end
end

View file

@ -0,0 +1,5 @@
class DropUsersTable < ActiveRecord::Migration
def change
drop_table :users
end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class UserSessionsControllerTest < ActionController::TestCase
def test_sanity
flunk "Need real tests"
end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class UsersControllerTest < ActionController::TestCase
def test_sanity
flunk "Need real tests"
end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class UserSessionsHelperTest < ActionView::TestCase
def test_sanity
flunk "Need real tests"
end
end

View file

@ -1,7 +0,0 @@
require "test_helper"
class UsersHelperTest < ActionView::TestCase
def test_sanity
flunk "Need real tests"
end
end

View file

@ -1,7 +1,6 @@
require "test_helper" require "test_helper"
class UserTest < ActiveSupport::TestCase class UserTest < ActiveSupport::TestCase
def user def user
@user ||= User.new @user ||= User.new
end end
@ -9,5 +8,4 @@ class UserTest < ActiveSupport::TestCase
def test_valid def test_valid
assert user.valid? assert user.valid?
end end
end end