From 47b425b5edbd19bec5cc1547635261cbfe92b995 Mon Sep 17 00:00:00 2001 From: Mike Slemmer Date: Thu, 15 Nov 2012 01:30:55 -0800 Subject: [PATCH] some more work --- lib/jam_ruby/models/user.rb | 20 +++++++++++++++++--- lib/jam_ruby/models/user_authorization.rb | 9 +++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/jam_ruby/models/user.rb b/lib/jam_ruby/models/user.rb index 6aa760ab0..d6df4a8b3 100644 --- a/lib/jam_ruby/models/user.rb +++ b/lib/jam_ruby/models/user.rb @@ -235,8 +235,18 @@ module JamRuby user.first_name = first_name user.last_name = last_name user.email = email - user.password = password - user.password_confirmation = password_confirmation + + #FIXME: Setting random password for social network logins. This + # is because we have validations all over the place on this. + # The right thing would be to have this null + if password.nil? + user.password = "blahblahblah" + user.password_confirmation = "blahblahblah" + else + user.password = password + user.password_confirmation = password_confirmation + end + user.admin = false user.email_confirmed = false user.city = city @@ -261,9 +271,13 @@ module JamRuby if user.errors.any? raise ActiveRecord::Rollback else + # FIXME: + # It's not standard to require a confirmation when a user signs up with Facebook. + # We should stop asking for it. + # # any errors here should also rollback the transaction; that's OK. If emails aren't going to be delivered, # it's already a really bad situation; make user signup again - UserMailer.welcome_message(user, signup_confirm_url + "/" + user.signup_token).deliver + UserMailer.welcome_message(user, signup_confirm_url.nil? ? nil : (signup_confirm_url + "/" + user.signup_token) ).deliver end end diff --git a/lib/jam_ruby/models/user_authorization.rb b/lib/jam_ruby/models/user_authorization.rb index 08230547f..5f7c97e25 100644 --- a/lib/jam_ruby/models/user_authorization.rb +++ b/lib/jam_ruby/models/user_authorization.rb @@ -1,11 +1,16 @@ module JamRuby class UserAuthorization < ActiveRecord::Base - self.table_name = "users_authorizations" + attr_accessible :provider, :uid, :token, :token_expiration + + self.table_name = "user_authorizations" self.primary_key = 'id' - belongs_to :user + belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id" validates :provider, :uid, :presence => true + + # token and token_expiration can be missing + end end