Permalink
Browse files

heroku was causing problems because I needed to change the db schema

  • Loading branch information...
1 parent ff7edc6 commit 716c6b9845e319381274ba7c97917e071d0df0d9 @lancejpollard committed Jun 1, 2010
@@ -15,7 +15,12 @@ def create
flash[:notice] = "Login successful!"
redirect_to current_user ? profile_url(current_user) : login_url
else
- render :action => :new
+ if @user_session.errors.on(:user)
+ # if we set error on the base object, likely it's because we didn't find a user
+ render :action => :confirm
+ else
+ render :action => :new
+ end
end
end
end
@@ -2,11 +2,6 @@ class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
before_filter :admin_only, :only => :detonate
- before_filter :show_sesh
-
- def show_sesh
- #puts "SESH: #{session.inspect}"
- end
def new
@user = User.new
@@ -20,7 +15,7 @@ def create
flash[:notice] = "Account registered!"
redirect_back_or_default profile_url(@user)
else
- render :action => :new
+ redirect_to login_url
end
end
end
@@ -35,6 +30,7 @@ def edit
end
def update
+ return create unless @current_user
@user = @current_user # makes our views "cleaner" and more consistent
@user.update_attributes(params[:user]) do |result|
if result
@@ -50,6 +46,6 @@ def update
def detonate
session.clear
User.all.collect(&:destroy)
- redirect_to signup_url
+ redirect_to login_url
end
end
View
@@ -1,5 +1,9 @@
class User < ActiveRecord::Base
- acts_as_authentic
+ acts_as_authentic do |config|
+ config.validate_email_field = false
+ config.validate_login_field = false
+ config.validate_password_field = false
+ end
include Profile
end
@@ -0,0 +1,14 @@
+%h2 Confirm
+%form.authentication_form{:action => signup_url, :method => :post}
+ %fieldset
+ / authentication_type should be "user" or "session", based on controller
+ - transfer = case session[:auth_method]
+ - when "oauth"
+ - %w(_key _token _secret auth_method oauth_provider)
+ - when "openid"
+ - %w(auth_method openid_identifier)
+ - transfer.each do |hidden|
+ %input{:type => :hidden, :name => hidden.to_sym, :value => session[hidden.to_sym]}
+ %input{:type => :hidden, :name => :authentication_type, :value => :user}
+ %input{:type => :text, :name => "user[email]"}
+ %input.submit{:name => :submit, :type => :submit, :value => "Register"}/
@@ -1,18 +1,19 @@
%h2 Login!
-%form#authentication_form{:action => authenticate_url, :method => :post}
+- form_for @user_session, :url => authenticate_path, :html => { :method => :post, :class => "authentication_form" } do |f|
+ = f.error_messages
+ / authentication_type should be "user" or "session", based on controller
+ = oauth_login_hidden_input
%fieldset
- %input{:type => :hidden, :name => :authentication_method, :value => :oauth}
- %input{:type => :hidden, :name => :authentication_type, :value => :session}
- %legend Click your Oauth or OpenID provider.
+ %legend Click your Oauth or OpenID provider
.oauth_providers
%ul
- - %w(google facebook twitter).each do |name|
+ - %w(google facebook twitter yahoo myspace linked_in).each do |name|
%li.oauth_provider
- %img{:src => "/images/icons/#{name}.png"}
- %input{:type => :radio, :id => "#{name}_oauth_provider", :name => :oauth_provider, :value => name}
+ = image_tag "/images/icons/#{name}.png"
+ = radio_button_tag :oauth_provider, name
.clearfix
%fieldset
%legend Or type in your OpenID address
.openid_address
- %input.nice{:type => :text, :name => "openid_identifier"}
- %input.submit{:name => :submit, :type => :submit, :value => "Register"}/
+ = text_field_tag :openid_identifier, nil, :class => :nice
+ = submit_tag "Login", :class => :submit
@@ -1,12 +1,12 @@
%h2 My Account
-%form#authentication_form{:action => connected_path, :method => :post}
+%form.authentication_form{:action => connected_path, :method => :post}
%fieldset
%input{:type => :hidden, :name => :authentication_type, :value => :user}
%input{:type => :hidden, :name => :_method, :value => :put}
%legend Add another Oauth or OpenID provider.
.oauth_providers
%ul
- - %w(google facebook twitter).each do |name|
+ - %w(google facebook twitter yahoo myspace linked_in).each do |name|
%li.oauth_provider
%img{:src => "/images/icons/#{name}.png"}
%input{:type => :radio, :id => "#{name}_oauth_provider", :name => :oauth_provider, :value => name}
@@ -15,4 +15,4 @@
%legend Or type in your OpenID address
.openid_address
%input.nice{:type => :text, :name => "openid_identifier"}
- %input.submit{:name => :submit, :type => :submit, :value => "Update"}/
+ %input.submit{:name => :submit, :type => :submit, :value => "Update"}/
@@ -1,12 +1,12 @@
-%h2 Login or Register!
-%form#authentication_form{:action => register_url, :method => :post}
+%h2 LogIn!
+%form.authentication_form{:action => signup_url, :method => :post}
%fieldset
/ authentication_type should be "user" or "session", based on controller
- %input{:type => :hidden, :name => :authentication_type, :value => :user}
+ %input{:type => :hidden, :name => :authentication_type, :value => current_user.nil? ? :user : :session}
%legend Click your Oauth or OpenID provider.
.oauth_providers
%ul
- - %w(google facebook twitter).each do |name|
+ - %w(google facebook twitter yahoo myspace linked_in).each do |name|
%li.oauth_provider
%img{:src => "/images/icons/#{name}.png"}
%input{:type => :radio, :id => "#{name}_oauth_provider", :name => :oauth_provider, :value => name}
View
@@ -1,15 +1,20 @@
ActionController::Routing::Routes.draw do |map|
map.connect '/', :controller => :users, :action => :new
- map.reset "reset", :controller => :users, :action => :detonate
- map.logout 'logout', :controller => :user_sessions, :action => :destroy
+
map.login 'login', :controller => :user_sessions, :action => :new
+ map.logout 'logout', :controller => :user_sessions, :action => :destroy, :conditions => {:method => :get}
map.authenticate 'authenticate', :controller => :user_sessions, :action => :create, :conditions => {:method => :post}
- map.signup 'signup', :controller => :users, :action => :new, :as => :signup
- map.register 'register', :controller => :users, :action => :create, :conditions => {:method => :post}
- map.connected 'connected', :controller => :users, :action => :update, :conditions => {:method => :put}
+
+ map.register 'register', :controller => :users, :action => :new
+ map.signup 'signup', :controller => :users, :action => :create, :conditions => {:method => :post}
+ map.connected 'connect', :controller => :users, :action => :update, :conditions => {:method => :put}
+
map.resources :users
map.resource :user_session
+ map.reset "reset", :controller => :users, :action => :detonate
+
map.profile ':id', :controller => :users, :action => :show
+
map.root :controller => 'users'
end
View
@@ -1,8 +0,0 @@
-Script started on Mon May 10 02:41:13 2010
-bash-3.2$
-bash-3.2$ xit
-bash: xit: command not found
-bash-3.2$ exit
-exit
-
-Script done on Mon May 10 02:41:16 2010
@@ -4,6 +4,7 @@ def self.up
# authlogic
t.timestamps
t.string :login, :null => true
+ t.string :email, :null => true
t.string :crypted_password, :null => true
t.string :password_salt, :null => true
t.string :persistence_token, :null => false
@@ -22,7 +23,7 @@ def self.up
add_index :users, :last_request_at
add_index :users, :active_token_id
end
-
+
def self.down
drop_table :users
end
@@ -1,6 +1,6 @@
-class CreateTokens < ActiveRecord::Migration
+class CreateAccessTokens < ActiveRecord::Migration
def self.up
- create_table :tokens do |t|
+ create_table :access_tokens do |t|
t.integer :user_id
t.string :type, :limit => 30
t.string :key # how we identify the user, in case they logout and log back in
@@ -10,11 +10,10 @@ def self.up
t.timestamps
end
- add_index :tokens, :key, :unique
- add_index :tokens, :token, :unique
+ add_index :access_tokens, :key, :unique
end
def self.down
- drop_table :tokens
+ drop_table :access_tokens
end
end
View
@@ -39,6 +39,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "login"
+ t.string "email"
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token", :null => false
@@ -2,7 +2,7 @@ $ = jQuery.noConflict();
Cufon.replace('h2, p, legend');
$(document).ready(function() {
- $form = $("#authentication_form");
+ $form = $(".authentication_form");
// progressively enhance buttons
$("li.oauth_provider").each(function(index, element) {
@@ -163,7 +163,7 @@ input#btn::-moz-focus-inner, input[type="button"]::-moz-focus-inner {
border : 0px;
}
-#authentication_form {
+.authentication_form {
clear:both;
width:501px;
height:45px;

0 comments on commit 716c6b9

Please sign in to comment.