remove database_authenticatable from user and fix paths

This commit is contained in:
benji 2015-03-21 17:58:49 +01:00
parent d687213834
commit 33ffcfdb9b
8 changed files with 20 additions and 19 deletions

View file

@ -23,7 +23,7 @@ class UserAvatarController < ApplicationController
def authenticate_session_user!
redirect_to root_path unless session[:id]
@user = User.find_by session[:id]
@user = User.find session[:id]
unless @user
reset_session
redirect_to root_path

View file

@ -26,7 +26,7 @@
#
class User < ActiveRecord::Base
devise :database_authenticatable, :trackable, :omniauthable, :omniauth_providers => [:zeuswpi]
devise :trackable, :omniauthable, :omniauth_providers => [:zeuswpi]
has_paper_trail only: [:debt_cents, :admin, :orders_count, :koelkast]
@ -43,12 +43,10 @@ class User < ActiveRecord::Base
scope :members, -> { where koelkast: false }
def self.from_omniauth(auth)
newuser = where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
end
newuser.password = Devise.friendly_token[0,20]
newuser
end
def nickname

View file

@ -16,11 +16,11 @@
<div class="hidden-xs navbar-form navbar-right">
<div class="form-group">
<% if user_signed_in? %>
<%= button_to "Logout", destroy_user_session_path, class: "btn btn-default form-control", method: :delete %>
<%= link_to "Logout", destroy_user_session_path, class: "btn btn-default form-control" %>
<% elsif session[:id] %>
<%= button_to "Logout", user_avatar_path(session[:id]), class: "btn btn-default form-control", method: :delete %>
<% else %>
<%= link_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Login", omniauth_authorize_path("user", "zeuswpi"), class: "btn btn-success form-control" %>
<% end %>
</div>
</div>
@ -62,7 +62,7 @@
<% if user_signed_in? %>
<%= button_to "Logout", destroy_user_session_path, class: "btn btn-default form-control", method: :delete %>
<% else %>
<%= link_to "Login", new_user_session_path, class: "btn btn-success form-control" %>
<%= link_to "Login", omniauth_authorize_path("user", "zeuswpi"), class: "btn btn-success form-control" %>
<% end %>
</div>
</div>

View file

@ -228,7 +228,7 @@ Devise.setup do |config|
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
config.sign_out_via = :get
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting

View file

@ -16,6 +16,7 @@ Rails.application.routes.draw do
authenticated :user, ->(u) { !u.koelkast? } do
root to: 'users#show', as: :user_root
end
get 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session
end
resources :users do

View file

@ -0,0 +1,5 @@
class RemoveEncryptedPasswordFromUsers < ActiveRecord::Migration
def change
remove_column :users, :encrypted_password, :string
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150320001338) do
ActiveRecord::Schema.define(version: 20150321161136) do
create_table "order_items", force: :cascade do |t|
t.integer "order_id"
@ -63,7 +63,6 @@ ActiveRecord::Schema.define(version: 20150320001338) do
t.boolean "koelkast", default: false
t.string "provider"
t.string "uid"
t.string "encrypted_password"
end
add_index "users", ["koelkast"], name: "index_users_on_koelkast"

View file

@ -67,16 +67,14 @@ users.each do |attr|
provider: attr[:provider],
avatar: attr[:avatar],
dagschotel: attr[:dagschotel],
password: DEFAULT_PASSWORD,
admin: attr[:admin] || false,
koelkast: attr[:koelkast] || false
)
end
50.times do |i|
User.create(
uid: "testUser#{i}",
avatar: users[0][:avatar],
password: DEFAULT_PASSWORD,
)
end
# 50.times do |i|
# User.create(
# uid: "testUser#{i}",
# avatar: users[0][:avatar],
# )
# end