Skip to content

Commit

Permalink
basic users
Browse files Browse the repository at this point in the history
  • Loading branch information
capnregex committed Nov 4, 2010
1 parent d8ee893 commit c87810a
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 130 deletions.
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ gem 'rails', '3.0.0.rc'
# gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'pg'
gem 'devise'
gem 'ruby-openid'
gem 'rack-openid'
gem 'devise_openid_authenticatable', :git => "git://github.com/nbudin/devise_openid_authenticatable.git"
gem 'ruby-openid-apps-discovery'
gem "devise_ldap_authenticatable", "0.4.4"
#gem "devise_ldap_authenticatable", :git => "git://github.com/cschiewek/devise_ldap_authenticatable.git"

# Use unicorn as the web server
# gem 'unicorn'
Expand Down
23 changes: 0 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
GIT
remote: git://github.com/nbudin/devise_openid_authenticatable.git
revision: 8c23a93
specs:
devise_openid_authenticatable (1.0.0.alpha6)
devise (>= 1.0.6)
rack-openid (>= 1.0.3)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -43,9 +35,6 @@ GEM
devise (1.1.1)
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)
devise_ldap_authenticatable (0.4.4)
devise (> 1.0.4)
net-ldap (>= 0.1.1)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
Expand All @@ -54,15 +43,11 @@ GEM
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
net-ldap (0.1.1)
pg (0.9.0)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.9)
rack (>= 1.0.0)
rack-openid (1.1.1)
rack (>= 0.4)
ruby-openid (>= 2.0.3)
rack-test (0.5.4)
rack (>= 1.0)
rails (3.0.0.rc)
Expand All @@ -79,9 +64,6 @@ GEM
rake (>= 0.8.3)
thor (~> 0.14.0)
rake (0.8.7)
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
ruby-openid (>= 2.1.7)
thor (0.14.0)
treetop (1.4.8)
polyglot (>= 0.3.1)
Expand All @@ -94,10 +76,5 @@ PLATFORMS

DEPENDENCIES
devise
devise_ldap_authenticatable (= 0.4.4)
devise_openid_authenticatable!
pg
rack-openid
rails (= 3.0.0.rc)
ruby-openid
ruby-openid-apps-discovery
42 changes: 6 additions & 36 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,14 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :openid_authenticatable, :registerable, :recoverable, :trackable, :validatable
# devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
# devise :openid_authenticatable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:token_authenticatable, :confirmable

# Setup accessible (or protected) attributes for your model
# attr_accessible :email, :password, :password_confirmation, :remember_me, :identity_url
attr_accessible :name, :email, :password, :password_confirmation, :remember_me

# Handle creation of user authenticated via OpenID
def self.create_from_identity_url(identity_url)
User.find_or_initialize_by_identity_url(identity_url)
def to_s
name || email
end

# Set email as a required field from the Open ID provider
def self.openid_required_fields
["email", "http://axschema.org/contact/email"]
end

# Accept fields from Open ID provider
def openid_fields=(fields)
fields.each do |key, value|
case key.to_s
when "email", "http://axschema.org/contact/email"
case value
when Array
self.email = value.first
else
self.email = value
end
if alt = self.class.find_by_email(email) and alt.id != id
self.id = alt.id
self.reload
@new_record = false
end
end
end

# Create this user
self.save!

end
end
2 changes: 1 addition & 1 deletion app/views/devise/menu/_registration_items.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if user_signed_in? %>
<li>
<%= link_to('Edit account', edit_user_registration_path) %>
<%= link_to(current_user, edit_user_registration_path) %>
</li>
<% else %>
<li>
Expand Down
3 changes: 3 additions & 0 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>

<p><%= f.label :name %><br />
<%= f.text_field :name %></p>

<p><%= f.label :email %><br />
<%= f.text_field :email %></p>

Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<p><%= f.label :identity_url %><br />
<%= f.text_field :identity_url %></p>
<p><%= f.label :name %><br />
<%= f.text_field :name %></p>

<p><%= f.label :email %><br />
<%= f.text_field :email %></p>
Expand Down
6 changes: 1 addition & 5 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<h2>Sign in</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>

<p><%= f.label :identity_url %><br />
<%= f.text_field :identity_url %></p>

<p><%= f.label :email %><br />
<%= f.text_field :email %></p>

Expand All @@ -18,4 +14,4 @@
<p><%= f.submit "Sign in" %></p>
<% end %>

<%= render :partial => "devise/shared/links" %>
<%= render :partial => "devise/shared/links" %>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= render 'devise/menu/registration_items' %>
<%= render 'devise/menu/login_items' %>
</ul>
<div id="title">Pathfinder Sheets</div>
<div id="title"><a href="/">Pathfinder Sheets</a></div>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
</div>
Expand Down
1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ class Application < Rails::Application
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :password_confirmation]

config.middleware.insert_before(Warden::Manager, Rack::OpenID)
end
end
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
config.encryptor = :bcrypt

# Setup a pepper to generate the encrypted password.
config.pepper = "4dda21a3b0da60adda7a8d0fa3a98e120618443e3e03ee3699823f20a395c6afb38027edf5bdfbc85810c3a005bec9c91368beb25c4c2bb6295e1af7540b9c69"
config.pepper = "44d61859aad32afab93602ac0cdc1f2527332d0782a9b0d91e75ace2a6b54177cdf2f3775d2f58575f80e04ea213f6f337bc36669c50d11d49bc852213d6a0a2"

# ==> Configuration for :confirmable
# The time you want to give your user to confirm his account. During this time
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
resources :characters

devise_for :users
resources :users, :only => [:index, :show]

# The priority is based upon order of creation:
# first created -> highest priority.
Expand Down
27 changes: 0 additions & 27 deletions db/migrate/20100820221903_devise_create_users.rb

This file was deleted.

20 changes: 0 additions & 20 deletions db/migrate/20100821001441_create_characters.rb

This file was deleted.

9 changes: 2 additions & 7 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100821001441) do
ActiveRecord::Schema.define(:version => 20101104191045) do

create_table "characters", :force => true do |t|
t.integer "user_id"
Expand All @@ -29,6 +29,7 @@
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "name", :limit => 40
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
Expand All @@ -37,22 +38,16 @@
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "identity_url"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
add_index "users", ["identity_url"], :name => "index_users_on_identity_url", :unique => true
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true

end
12 changes: 12 additions & 0 deletions public/stylesheets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
border-bottom: solid 1px #000;
}

#header a {
text-decoration:none;
}

#header a,
#header a:link,
#header a:visited,
#header a:hover {
color:#000000;
background:none;
}

#title {
font-size: 3em;
font-family:serif;
Expand Down

0 comments on commit c87810a

Please sign in to comment.