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-15 03:24:42 +00:00
|
|
|
def signup(first_name, last_name, email, password, password_confirmation,
|
2012-11-14 05:37:50 +00:00
|
|
|
city, state, country, instruments, signup_confirm_url)
|
|
|
|
|
|
|
|
|
|
@user = User.new
|
|
|
|
|
|
2012-11-14 05:57:10 +00:00
|
|
|
# TODO: figure out why can't user verify_recaptcha here
|
|
|
|
|
|
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
|
2012-11-14 05:37:50 +00:00
|
|
|
# sends email to email account for confirmation
|
2012-11-15 03:24:42 +00:00
|
|
|
@user = User.signup(first_name, last_name, email, password, password_confirmation,
|
2012-11-14 05:37:50 +00:00
|
|
|
city, state, country, instruments, signup_confirm_url)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
end
|