some more work

This commit is contained in:
Mike Slemmer 2012-11-15 01:30:55 -08:00
parent 436495b751
commit 47b425b5ed
2 changed files with 24 additions and 5 deletions

View File

@ -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

View File

@ -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