Merge branch 'master' of bitbucket.org:jamkazam/jam-ruby

This commit is contained in:
Brian Smith 2012-11-15 21:08:42 -05:00
commit 35126ad7a6
3 changed files with 37 additions and 3 deletions

View File

@ -22,6 +22,7 @@ require "jam_ruby/tire_tasks"
require "jam_ruby/message_factory"
require "jam_ruby/models/genre"
require "jam_ruby/models/user"
require "jam_ruby/models/user_authorization"
require "jam_ruby/models/band"
require "jam_ruby/models/connection"
require "jam_ruby/models/friendship"

View File

@ -7,6 +7,9 @@ module JamRuby
self.primary_key = 'id'
# authorizations (for facebook, etc -- omniauth)
has_many :user_authorizations, :class_name => "JamRuby::UserAuthorization"
# account
belongs_to :account, :class_name => "JamRuby::Account"
@ -234,8 +237,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
@ -260,9 +273,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

@ -0,0 +1,16 @@
module JamRuby
class UserAuthorization < ActiveRecord::Base
attr_accessible :provider, :uid, :token, :token_expiration
self.table_name = "user_authorizations"
self.primary_key = 'id'
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