jam-cloud/lib/managers/user_manager.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

2012-11-14 05:37:50 +00:00
require 'recaptcha'
class UserManager < BaseManager
include Recaptcha::Verify
def initialize(options={})
super(options)
@log = Logging.logger[self]
end
2012-11-30 09:36:41 +00:00
# Note that almost everything can be nil here. This is because when users sign up via social media,
# we don't know much about them.
def signup(remote_ip, first_name, last_name, email, password = nil, password_confirmation = nil,
instruments = nil, photo_url = nil, signup_confirm_url = nil)
2012-11-14 05:37:50 +00:00
@user = User.new
location_hash = MaxMindManager.lookup(remote_ip);
2012-11-14 05:57:10 +00:00
# TODO: figure out why can't user verify_recaptcha here
2012-11-15 08:47:19 +00:00
# ALSO: make sure we dont do the recaptcha stuff if used facebook.
2012-11-14 05:57:10 +00:00
2012-11-14 05:37:50 +00:00
# check recaptcha; if any errors seen, contribute it to the model
2012-11-14 05:57:10 +00:00
#unless verify_recaptcha(:model => @user, :message => "recaptcha")
# return @user # @user.errors.any? is true now
#else
# sends email to email account for confirmation
@user = User.signup(first_name, last_name, email, password, password_confirmation,
location_hash[:city], location_hash[:state], location_hash[:country],
instruments, photo_url, signup_confirm_url)
2012-11-14 05:37:50 +00:00
return @user
2012-11-14 05:57:10 +00:00
#end
2012-11-14 05:37:50 +00:00
end
def signup_confirm(signup_token)
begin
@user = User.signup_confirm(signup_token)
rescue ActiveRecord::RecordNotFound
@user = nil
end
return @user
end
2012-11-15 08:47:19 +00:00
end