From d4a5737c515234d072ad7f24815928a324a84971 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 3 Feb 2014 21:19:14 +0000 Subject: [PATCH 01/21] * VRFS-1025 finished --- db/manifest | 3 +- db/up/facebook_signup.sql | 16 + ruby/lib/jam_ruby.rb | 2 + ruby/lib/jam_ruby/models/facebook_signup.rb | 15 + ruby/lib/jam_ruby/models/user.rb | 70 ++++- .../lib/jam_ruby/models/user_authorization.rb | 4 +- .../scheduled/cleanup_facebook_signup.rb | 19 ++ ruby/spec/factories.rb | 10 + .../jam_ruby/models/facebook_signup_spec.rb | 20 ++ ruby/spec/jam_ruby/models/user_spec.rb | 28 ++ web/app/assets/javascripts/jamkazam.js | 5 + web/app/assets/javascripts/layout.js | 16 + .../assets/javascripts/web/signinDialog.js | 43 +++ .../assets/javascripts/web/signupDialog.js | 8 +- web/app/assets/javascripts/web/web.js | 1 + web/app/assets/javascripts/web/welcome.js | 6 + web/app/controllers/api_users_controller.rb | 26 -- web/app/controllers/sessions_controller.rb | 48 ++- web/app/controllers/users_controller.rb | 114 +++++-- web/app/views/layouts/web.erb | 4 + web/app/views/users/_signinDialog.html.erb | 58 ++++ web/app/views/users/_signupDialog.html.erb | 6 +- web/config/application.rb | 3 + web/config/environments/production.rb | 3 + web/config/environments/test.rb | 3 + web/config/initializers/omniauth.rb | 2 +- web/config/scheduler.yml | 6 +- web/lib/user_manager.rb | 34 ++- .../controllers/sessions_controller_spec.rb | 12 - web/spec/factories.rb | 11 +- web/spec/features/signup_spec.rb | 11 +- web/spec/features/welcome_spec.rb | 66 +++++ web/spec/managers/user_manager_spec.rb | 278 ++++++++++++++++-- web/spec/spec_helper.rb | 3 + 34 files changed, 830 insertions(+), 124 deletions(-) create mode 100644 db/up/facebook_signup.sql create mode 100644 ruby/lib/jam_ruby/models/facebook_signup.rb create mode 100644 ruby/lib/jam_ruby/resque/scheduled/cleanup_facebook_signup.rb create mode 100644 ruby/spec/jam_ruby/models/facebook_signup_spec.rb create mode 100644 web/app/assets/javascripts/web/signinDialog.js create mode 100644 web/app/views/users/_signinDialog.html.erb create mode 100644 web/spec/features/welcome_spec.rb diff --git a/db/manifest b/db/manifest index ec3b567a2..25fd574e1 100755 --- a/db/manifest +++ b/db/manifest @@ -96,4 +96,5 @@ ms_user_history_add_instruments.sql icecast_config_changed.sql invited_users_facebook_support.sql first_recording_at.sql -share_token.sql \ No newline at end of file +share_token.sql +facebook_signup.sql \ No newline at end of file diff --git a/db/up/facebook_signup.sql b/db/up/facebook_signup.sql new file mode 100644 index 000000000..d27ec0cdd --- /dev/null +++ b/db/up/facebook_signup.sql @@ -0,0 +1,16 @@ +-- when a user authorizes our application to signup, we create this row +CREATE UNLOGGED TABLE facebook_signups ( + id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(), + lookup_id VARCHAR(255) UNIQUE NOT NULL, + last_name VARCHAR(100), + first_name VARCHAR(100), + gender VARCHAR(1), + email VARCHAR(1024), + uid VARCHAR(1024), + token VARCHAR(1024), + token_expires_at TIMESTAMP, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +ALTER TABLE user_authorizations ADD CONSTRAINT user_authorizations_uniqkey UNIQUE (provider, uid); \ No newline at end of file diff --git a/ruby/lib/jam_ruby.rb b/ruby/lib/jam_ruby.rb index 6ab7a51bb..aa036793d 100755 --- a/ruby/lib/jam_ruby.rb +++ b/ruby/lib/jam_ruby.rb @@ -35,6 +35,7 @@ require "jam_ruby/resque/resque_hooks" require "jam_ruby/resque/scheduled/audiomixer_retry" require "jam_ruby/resque/scheduled/icecast_config_retry" require "jam_ruby/resque/scheduled/icecast_source_check" +require "jam_ruby/resque/scheduled/cleanup_facebook_signup" require "jam_ruby/mq_router" require "jam_ruby/base_manager" require "jam_ruby/connection_manager" @@ -117,6 +118,7 @@ require "jam_ruby/models/icecast_server_socket" require "jam_ruby/models/icecast_template_socket" require "jam_ruby/models/icecast_server_group" require "jam_ruby/models/icecast_mount_template" +require "jam_ruby/models/facebook_signup" include Jampb diff --git a/ruby/lib/jam_ruby/models/facebook_signup.rb b/ruby/lib/jam_ruby/models/facebook_signup.rb new file mode 100644 index 000000000..9e232b2a1 --- /dev/null +++ b/ruby/lib/jam_ruby/models/facebook_signup.rb @@ -0,0 +1,15 @@ +module JamRuby + class FacebookSignup < ActiveRecord::Base + + before_create :generate_lookup_id + + def self.delete_old + FacebookSignup.where("created_at < :week", {:week => 1.week.ago}).delete_all + end + + private + def generate_lookup_id + self.lookup_id = SecureRandom.urlsafe_base64 + end + end +end diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 00011b407..e137b8a81 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -697,8 +697,23 @@ module JamRuby # throws ActiveRecord::RecordNotFound if instrument is invalid # throws an email delivery error if unable to connect out to SMTP - def self.signup(first_name, last_name, email, password, password_confirmation, terms_of_service, - location, instruments, birth_date, musician, photo_url, invited_user, signup_confirm_url) + def self.signup(options) + + first_name = options[:first_name] + last_name = options[:last_name] + email = options[:email] + password = options[:password] + password_confirmation = options[:password_confirmation] + terms_of_service = options[:terms_of_service] + location = options[:location] + instruments = options[:instruments] + birth_date = options[:birth_date] + musician = options[:musician] + photo_url = options[:photo_url] + invited_user = options[:invited_user] + fb_signup = options[:fb_signup] + signup_confirm_url = options[:signup_confirm_url] + user = User.new UserManager.active_record_transaction do |user_manager| @@ -744,11 +759,25 @@ module JamRuby user.photo_url = photo_url + unless fb_signup.nil? + user.update_fb_authorization(fb_signup) + + if fb_signup.email.casecmp(user.email).zero? + user.email_confirmed = true + user.signup_token = nil + else + user.email_confirmed = false + user.signup_token = SecureRandom.urlsafe_base64 + end + end if invited_user.nil? user.can_invite = Limits::USERS_CAN_INVITE - user.email_confirmed = false - user.signup_token = SecureRandom.urlsafe_base64 + + unless user.email_confirmed # important that the only time this goes true is if some other mechanism, like fb_signup, set this high + user.email_confirmed = false + user.signup_token = SecureRandom.urlsafe_base64 + end else # if you are invited by an admin, we'll say you can invite too. # but if not, then you can not invite @@ -785,15 +814,10 @@ module JamRuby if user.errors.any? raise ActiveRecord::Rollback else - # don't send an signup email if the user was invited already *and* they used the same email that they were invited with - if !invited_user.nil? && invited_user.email.casecmp(user.email).zero? + # don't send an signup email if email is already confirmed + if user.email_confirmed UserMailer.welcome_message(user).deliver 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.confirm_email(user, signup_confirm_url.nil? ? nil : (signup_confirm_url + "/" + user.signup_token) ).deliver @@ -941,6 +965,30 @@ module JamRuby end end + # updates an existing user_authorization for facebook, or creates a new one if none exist + def update_fb_authorization(fb_signup) + if fb_signup.uid && fb_signup.token && fb_signup.token_expires_at + + user_authorization = nil + + unless self.new_record? + # see if this user has an existing user_authorization for this provider + user_authorization = UserAuthorization.find_by_user_id_and_provider(self.id, 'facebook') + end + + if user_authorization.nil? + self.user_authorizations.build provider: 'facebook', + uid: fb_signup.uid, + token: fb_signup.token, + token_expiration: fb_signup.token_expires_at + else + user_authorization.uid = fb_signup.uid + user_authorization.token = fb_signup.token + user_authorization.token_expiration = fb_signup.token_expires_at + end + end + end + def provides_location? !self.city.blank? && (!self.state.blank? || !self.country.blank?) end diff --git a/ruby/lib/jam_ruby/models/user_authorization.rb b/ruby/lib/jam_ruby/models/user_authorization.rb index 5f7c97e25..47061e17e 100644 --- a/ruby/lib/jam_ruby/models/user_authorization.rb +++ b/ruby/lib/jam_ruby/models/user_authorization.rb @@ -9,8 +9,10 @@ module JamRuby belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id" validates :provider, :uid, :presence => true + validates_uniqueness_of :uid, scope: :provider # token and token_expiration can be missing - + + end end diff --git a/ruby/lib/jam_ruby/resque/scheduled/cleanup_facebook_signup.rb b/ruby/lib/jam_ruby/resque/scheduled/cleanup_facebook_signup.rb new file mode 100644 index 000000000..a2cbab476 --- /dev/null +++ b/ruby/lib/jam_ruby/resque/scheduled/cleanup_facebook_signup.rb @@ -0,0 +1,19 @@ + +module JamRuby + class CleanupFacebookSignup + + @queue = :cleanup_facebook_signup + + @@log = Logging.logger[CleanupFacebookSignup] + + + def self.perform + @@log.debug("waking up") + + FacebookSignup.delete_old + + @@log.debug("done") + end + + end +end diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 68b71c553..a8eda4e0a 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -317,4 +317,14 @@ FactoryGirl.define do association :authentication, :factory => :icecast_user_authentication end + factory :facebook_signup, :class => JamRuby::FacebookSignup do + sequence(:lookup_id) { |n| "lookup-#{n}"} + sequence(:first_name) { |n| "first-#{n}"} + sequence(:last_name) { |n| "last-#{n}"} + gender 'M' + sequence(:email) { |n| "jammin-#{n}@jamkazam.com"} + sequence(:uid) { |n| "uid-#{n}"} + sequence(:token) { |n| "token-#{n}"} + token_expires_at Time.now + end end diff --git a/ruby/spec/jam_ruby/models/facebook_signup_spec.rb b/ruby/spec/jam_ruby/models/facebook_signup_spec.rb new file mode 100644 index 000000000..6edbab157 --- /dev/null +++ b/ruby/spec/jam_ruby/models/facebook_signup_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe FacebookSignup do + + it "does not delete new one" do + new_signup = FactoryGirl.create(:facebook_signup) + + FacebookSignup.delete_old + + FacebookSignup.find(new_signup) + end + + it "does delete old one" do + old_signup = FactoryGirl.create(:facebook_signup, :created_at => 10.days.ago) + + FacebookSignup.delete_old + + FacebookSignup.find_by_id(old_signup.id).should be_nil + end +end diff --git a/ruby/spec/jam_ruby/models/user_spec.rb b/ruby/spec/jam_ruby/models/user_spec.rb index a29179a8a..a069e7ee0 100644 --- a/ruby/spec/jam_ruby/models/user_spec.rb +++ b/ruby/spec/jam_ruby/models/user_spec.rb @@ -397,6 +397,34 @@ describe User do end end + describe "user_authorizations" do + + it "can create" do + @user.user_authorizations.build provider: 'facebook', + uid: '1', + token: '1', + token_expiration: Time.now + @user.save! + end + + it "fails on duplicate" do + @user.user_authorizations.build provider: 'facebook', + uid: '1', + token: '1', + token_expiration: Time.now + @user.save! + + @user2 = FactoryGirl.create(:user) + @user2.user_authorizations.build provider: 'facebook', + uid: '1', + token: '1', + token_expiration: Time.now + @user2.save.should be_false + @user2.errors[:user_authorizations].should == ['is invalid'] + end + + + end =begin describe "update avatar" do diff --git a/web/app/assets/javascripts/jamkazam.js b/web/app/assets/javascripts/jamkazam.js index d9ec02fba..108c7753a 100644 --- a/web/app/assets/javascripts/jamkazam.js +++ b/web/app/assets/javascripts/jamkazam.js @@ -322,10 +322,15 @@ var hash = context.location.hash; + if(!this.layout.isScreenName(hash)) { + hash = null; + } + var url = '#/home'; if (hash) { url = hash; } + logger.debug("Changing screen to " + url); context.location = url; } diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index 53bac88fa..979a73d5d 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -428,6 +428,18 @@ dialogEvent(dialog, 'afterHide'); } + function isScreenName(screenName) { + if(!screenName) return false; + + var hashIndex = screenName.indexOf('#'); + + if(hashIndex > -1) { + screenName = screenName.substr(hashIndex); + } + + return screenBindings[screenName]; + } + function screenEvent(screen, evtName, data) { if (screen && screen in screenBindings) { if (evtName in screenBindings[screen]) { @@ -752,6 +764,10 @@ }; }; + this.isScreenName = function(screenName) { + return isScreenName(screenName); + } + this.bindScreen = function(screen, handler) { screenBindings[screen] = handler; }; diff --git a/web/app/assets/javascripts/web/signinDialog.js b/web/app/assets/javascripts/web/signinDialog.js new file mode 100644 index 000000000..aded10b15 --- /dev/null +++ b/web/app/assets/javascripts/web/signinDialog.js @@ -0,0 +1,43 @@ +(function(context,$) { + + "use strict"; + + context.JK = context.JK || {}; + + context.JK.SigninDialog = function(app) { + var logger = context.JK.logger; + var rest = context.JK.Rest(); + var dialogId = '#signin-dialog'; + + function events() { + $(dialogId + ' .signin-cancel').click(function(e) { + app.layout.closeDialog('signin-dialog'); + e.stopPropagation(); + return false; + }); + } + + function beforeShow() { + + } + + function afterHide() { + + } + + function initialize(){ + + var dialogBindings = { + 'beforeShow' : beforeShow, + 'afterHide': afterHide + }; + + app.bindDialog('signin-dialog', dialogBindings); + + events(); + } + + this.initialize = initialize; + + } +})(window, jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/web/signupDialog.js b/web/app/assets/javascripts/web/signupDialog.js index 459833503..2c85ac2f7 100644 --- a/web/app/assets/javascripts/web/signupDialog.js +++ b/web/app/assets/javascripts/web/signupDialog.js @@ -10,8 +10,11 @@ var dialogId = '#signup-dialog'; function events() { - - + $(dialogId + ' .signup-cancel').click(function(e) { + app.layout.closeDialog('signup-dialog'); + e.stopPropagation(); + return false; + }); } function beforeShow() { @@ -31,7 +34,6 @@ app.bindDialog('signup-dialog', dialogBindings); - console.log("honuth") events(); } diff --git a/web/app/assets/javascripts/web/web.js b/web/app/assets/javascripts/web/web.js index c6489a530..ea049bbd4 100644 --- a/web/app/assets/javascripts/web/web.js +++ b/web/app/assets/javascripts/web/web.js @@ -6,6 +6,7 @@ //= require AAC_underscore //= require globals //= require web/signupDialog +//= require web/signinDialog //= require invitationDialog //= require shareDialog //= require layout diff --git a/web/app/assets/javascripts/web/welcome.js b/web/app/assets/javascripts/web/welcome.js index 7d4728e03..55ed205a1 100644 --- a/web/app/assets/javascripts/web/welcome.js +++ b/web/app/assets/javascripts/web/welcome.js @@ -10,6 +10,12 @@ e.preventDefault(); return false; }); + + $('#signin').click(function(e) { + context.JK.app.layout.showDialog('signin-dialog'); + e.preventDefault(); + return false; + }); } initialize() diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 0565d95b5..01eb5107e 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -27,32 +27,6 @@ class ApiUsersController < ApiController respond_with @user, responder: ApiResponder, :status => 200 end - # this API call is disabled by virtue of it being commented out in routes.rb - # the reason is that it has no captcha, and is therefore a bit abuseable - # if someone wants to use it, please add in captcha or some other bot-protector - def create - # sends email to email account for confirmation - @user = UserManager.new.signup(params[:first_name], - params[:last_name], - params[:email], - params[:password], - params[:password_confirmation], - params[:city], - params[:state], - params[:country], - params[:instruments], - params[:photo_url], - ApplicationHelper.base_uri(request) + "/confirm") - - # check for errors - unless @user.errors.any? - render :json => {}, :status => :ok # an empty response, but 200 OK - else - response.status = :unprocessable_entity - respond_with @user, responder: ApiResponder - end - end - def update @user = User.find(params[:id]) diff --git a/web/app/controllers/sessions_controller.rb b/web/app/controllers/sessions_controller.rb index 45e019b27..019c52b99 100644 --- a/web/app/controllers/sessions_controller.rb +++ b/web/app/controllers/sessions_controller.rb @@ -48,15 +48,10 @@ class SessionsController < ApplicationController # an email and whatnot. # # Also, should we grab their photo from facebook? - user = UserManager.new.signup(remote_ip(), - auth_hash[:info][:first_name], - auth_hash[:info][:last_name], - auth_hash[:info][:email], - nil, - nil, - nil, # instruments - nil, # photo_url - nil) + user = UserManager.new.signup(remote_ip: remote_ip(), + first_name: auth_hash[:info][:first_name], + last_name: auth_hash[:info][:last_name], + email: auth_hash[:info][:email]) # Users who sign up using oauth are presumed to have valid email adddresses. user.confirm_email! @@ -72,18 +67,49 @@ class SessionsController < ApplicationController def oauth_callback + + auth_hash = request.env['omniauth.auth'] + + provider = auth_hash[:provider] + + if provider == 'facebook' + fb_uid = auth_hash[:uid] + token = auth_hash[:credentials][:token] + token_expiration = Time.at(auth_hash[:credentials][:expires_at]) + first_name = auth_hash[:extra][:raw_info][:first_name] + last_name = auth_hash[:extra][:raw_info][:last_name] + email = auth_hash[:extra][:raw_info][:email] + gender = auth_hash[:extra][:raw_info][:gender] + + fb_signup = FacebookSignup.new + fb_signup.uid = fb_uid + fb_signup.token = token + fb_signup.token_expires_at = token_expiration + fb_signup.first_name = first_name + fb_signup.last_name = last_name + fb_signup.email = email + if gender == 'male' + fb_signup.gender = 'M' + elsif gender == 'female' + fb_signup.gender = 'F' + end + fb_signup.save! + + redirect_to "#{signup_path}?facebook_signup=#{fb_signup.lookup_id}" + return + end + if current_user.nil? render :nothing => true, :status => 404 return end - auth_hash = request.env['omniauth.auth'] #authorization = UserAuthorization.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"]) # Always make and save a new authorization. This is because they expire, and honestly there's no cost # to just making and saving it. #if authorization.nil? - authorization = current_user.user_authorizations.build :provider => auth_hash[:provider], + authorization = current_user.user_authorizations.build :provider => auth_hash[:provider], :uid => auth_hash[:uid], :token => auth_hash[:credentials][:token], :token_expiration => Time.at(auth_hash[:credentials][:expires_at]) diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index e2aae2132..6c98a031d 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -27,6 +27,33 @@ class UsersController < ApplicationController return end + @fb_signup = load_facebook_signup(params) + + + # check if the email specified by @fb_signup already exists in the databse--if so, log them in and redirect + if @fb_signup && @fb_signup.email + user = User.find_by_email_and_email_confirmed(@fb_signup, true) + if user + # update user_authorization for user because this is fresher + user.update_fb_authorization(@fb_signup) + sign_in(user) + redirect_to client_url + return + end + end + + # check if the uid specified by @fb_signup already exists in the databse--if so, log them in and redirect + if @fb_signup && @fb_signup.uid + user_authorization = UserAuthorization.find_by_uid_and_provider(@fb_signup.uid, 'facebook') + # update user_authorization for user because this is fresher + if user_authorization + user_authorization.user.update_fb_authorization(@fb_signup) + sign_in(user_authorization.user) + redirect_to client_url + return + end + end + @invited_user = load_invited_user(params) if !@invited_user.nil? && @invited_user.has_required_email? && @invited_user.accepted @@ -34,7 +61,7 @@ class UsersController < ApplicationController render "already_signed_up", :layout => 'landing' return end - @signup_postback = load_postback(@invited_user) + @signup_postback = load_postback(@invited_user, @fb_signup) load_location(request.remote_ip) @@ -42,21 +69,54 @@ class UsersController < ApplicationController @user.musician = true # default the UI to musician as selected option # preseed the form with the invited email as a convenience to the user - unless @invited_user.nil? - @user.email = @invited_user.email + @user.email = @invited_user.email unless @invited_user.nil? + + if @fb_signup + @user.email = @fb_signup.email + @user.first_name = @fb_signup.first_name + @user.last_name = @fb_signup.last_name + @user.gender = @fb_signup.gender end render :layout => 'web' end def create + if current_user redirect_to client_url return end + @fb_signup = load_facebook_signup(params) + + # check if the email specified by @fb_signup already exists in the databse--if so, log them in and redirect + if @fb_signup && @fb_signup.email + user = User.find_by_email_and_email_confirmed(@fb_signup, true) + if user + # update user_authorization for user because this is fresher + user.update_fb_authorization(@fb_signup) + sign_in(user) + redirect_to client_url + return + end + end + + # check if the uid specified by @fb_signup already exists in the databse--if so, log them in and redirect + if @fb_signup && @fb_signup.uid + user_authorization = UserAuthorization.find_by_uid_and_provider(@fb_signup.uid, 'facebook') + # update user_authorization for user because this is fresher + if user_authorization + user_authorization.user.update_fb_authorization(@fb_signup) + sign_in(user_authorization.user) + redirect_to client_url + return + end + + end + @invited_user = load_invited_user(params) - @signup_postback = load_postback(@invited_user) + @signup_postback = load_postback(@invited_user, @fb_signup) @user = User.new @@ -73,21 +133,20 @@ class UsersController < ApplicationController terms_of_service = params[:jam_ruby_user][:terms_of_service].nil? ? false : true musician = params[:jam_ruby_user][:musician] - - @user = UserManager.new.signup(request.remote_ip, - params[:jam_ruby_user][:first_name], - params[:jam_ruby_user][:last_name], - params[:jam_ruby_user][:email], - params[:jam_ruby_user][:password], - params[:jam_ruby_user][:password_confirmation], - terms_of_service, - instruments, - birth_date, - location, - musician, - nil, # we don't accept photo url on the signup form yet - @invited_user, - ApplicationHelper.base_uri(request) + "/confirm") + @user = UserManager.new.signup(remote_ip: request.remote_ip, + first_name: params[:jam_ruby_user][:first_name], + last_name: params[:jam_ruby_user][:last_name], + email: params[:jam_ruby_user][:email], + password: params[:jam_ruby_user][:password], + password_confirmation: params[:jam_ruby_user][:password_confirmation], + terms_of_service: terms_of_service, + instruments: instruments, + birth_date: birth_date, + location: location, + musician: musician, + invited_user: @invited_user, + fb_signup: @fb_signup, + signup_confirm_url: ApplicationHelper.base_uri(request) + "/confirm") # check for errors if @user.errors.any? @@ -308,6 +367,12 @@ class UsersController < ApplicationController return Date.new(year.to_i, month.to_i, day.to_i) end + def load_facebook_signup(params) + lookup_id = params[:facebook_signup] + + FacebookSignup.find_by_lookup_id(lookup_id) + end + def load_invited_user(params) # check if this an anonymous request, or result of invitation code invitation_code = params[:invitation_code] @@ -336,11 +401,10 @@ class UsersController < ApplicationController @cities = @location[:state].nil? ? [] : MaxMindManager.cities(@location[:country], @location[:state]) end - def load_postback(invited_user) - if invited_user.nil? - signup_path - else - signup_path + "?invitation_code=" + invited_user.invitation_code - end + def load_postback(invited_user, fb_signup) + query = {} + query[:invitation_code] = invited_user.invitation_code if invited_user + query[:facebook_signup] = fb_signup.lookup_id if fb_signup + signup_path + "?" + params.to_query end end diff --git a/web/app/views/layouts/web.erb b/web/app/views/layouts/web.erb index 58c07dd86..28f55c2f9 100644 --- a/web/app/views/layouts/web.erb +++ b/web/app/views/layouts/web.erb @@ -50,6 +50,7 @@ <%= render "clients/invitationDialog" %> <%= render "users/signupDialog" %> + <%= render "users/signinDialog" %> diff --git a/web/app/views/users/_signinDialog.html.erb b/web/app/views/users/_signinDialog.html.erb new file mode 100644 index 000000000..9dc8df8a0 --- /dev/null +++ b/web/app/views/users/_signinDialog.html.erb @@ -0,0 +1,58 @@ +
+ + +
+

sign in

+
+ + +
+ + <%= link_to image_tag("content/button_facebook_signin.png", {:width => 249, :height => 46 }), '/auth/facebook', class: "signin-facebook" %> + +
+
+
+ Or sign in with JamKazam Account +
+
+ +
+ + + + + + + + + + + + + +
Email Address:
+

+
Password:
+
+ Keep me signed in +

+ + +
+
+ +
+ +
+ Don't have an account? Sign Up +
+
+ +
+
\ No newline at end of file diff --git a/web/app/views/users/_signupDialog.html.erb b/web/app/views/users/_signupDialog.html.erb index 9484902a5..6b19e7b1e 100644 --- a/web/app/views/users/_signupDialog.html.erb +++ b/web/app/views/users/_signupDialog.html.erb @@ -8,7 +8,7 @@
- <%= image_tag "content/button_facebook_signup.png", {:width => 249, :height => 46 } %> + <%= link_to image_tag("content/button_facebook_signup.png", {:width => 249, :height => 46 }), '/auth/facebook', class: "signup-facebook" %>


@@ -16,14 +16,14 @@

-
<%= link_to "SIGN UP WITH YOUR EMAIL", signup_path, class: "button-orange block" %> +
<%= link_to "SIGN UP WITH YOUR EMAIL", signup_path, class: "button-orange block signup-email" %>
Already have an account?

- Cancel
+
diff --git a/web/config/application.rb b/web/config/application.rb index f6050245a..bc41c2612 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -194,5 +194,8 @@ include JamRuby config.email_smtp_user_name = 'jamkazam' config.email_smtp_password = 'jamjamblueberryjam' config.email_smtp_starttls_auto = true + + config.facebook_app_id = '468555793186398' + config.facebook_app_secret = '546a5b253972f3e2e8b36d9a3dd5a06e' end end diff --git a/web/config/environments/production.rb b/web/config/environments/production.rb index 61a091e10..04d979d01 100644 --- a/web/config/environments/production.rb +++ b/web/config/environments/production.rb @@ -86,4 +86,7 @@ SampleApp::Application.configure do config.fp_secret = 'HZBIMSOI5VAQ5LXT4XLG6XA7IE' config.allow_force_native_client = false + + config.facebook_app_id = '1412328362347190' # staging + config.facebook_app_secret = '8b1f20430356d44fb49c0a504a9ff401' # staging end diff --git a/web/config/environments/test.rb b/web/config/environments/test.rb index a7983a303..b164e765c 100644 --- a/web/config/environments/test.rb +++ b/web/config/environments/test.rb @@ -59,5 +59,8 @@ SampleApp::Application.configure do config.aws_secret_access_key = 'h0V0ffr3JOp/UtgaGrRfAk25KHNiO9gm8Pj9m6v3' config.icecast_wait_after_reload = 0 + + config.facebook_app_id = '1441492266082868' + config.facebook_app_secret = '233bd040a07e47dcec1cff3e490bfce7' end diff --git a/web/config/initializers/omniauth.rb b/web/config/initializers/omniauth.rb index 243e880cf..0dba7848d 100644 --- a/web/config/initializers/omniauth.rb +++ b/web/config/initializers/omniauth.rb @@ -1,5 +1,5 @@ Rails.application.config.middleware.use OmniAuth::Builder do - provider :facebook, '468555793186398', '546a5b253972f3e2e8b36d9a3dd5a06e', {name: "facebook", :scope => 'email,user_location'} + provider :facebook, Rails.application.config.facebook_app_id, Rails.application.config.facebook_app_secret, {name: "facebook", :scope => 'email,user_location'} provider :google_oauth2, Rails.application.config.google_client_id, Rails.application.config.google_secret, {name: "google_login", approval_prompt: '', scope: 'userinfo.email, userinfo.profile, https://www.google.com/m8/feeds'} end diff --git a/web/config/scheduler.yml b/web/config/scheduler.yml index 8a6dde7df..10fd84d55 100644 --- a/web/config/scheduler.yml +++ b/web/config/scheduler.yml @@ -9,9 +9,13 @@ IcecastConfigRetry: class: "JamRuby::IcecastConfigRetry" description: "Finds icecast servers that have had their config_changed, but no IcecastConfigWriter check recently" - IcecastSourceCheck: cron: "10 * * * * *" class: "JamRuby::IcecastSourceCheck" description: "Finds icecast mounts that need their 'sourced' state to change, but haven't in some time" +CleanupFacebookSignup: + cron: "30 2 * * *" + class: "JamRuby::CleanupFacebookSignup" + description: "Deletes facebook_signups that are old" + diff --git a/web/lib/user_manager.rb b/web/lib/user_manager.rb index c4f4fdaec..728bcb652 100644 --- a/web/lib/user_manager.rb +++ b/web/lib/user_manager.rb @@ -10,8 +10,22 @@ class UserManager < BaseManager # 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, terms_of_service = nil, - instruments = nil, birth_date = nil, location = nil, musician = nil, photo_url = nil, invited_user = nil, signup_confirm_url = nil) + def signup(options) + remote_ip = options[:remote_ip] + first_name = options[:first_name] + last_name = options[:last_name] + email = options[:email] + password = options[:password] + password_confirmation = options[:password_confirmation] + terms_of_service = options[:terms_of_service] + instruments = options[:instruments] + birth_date = options[:birth_date] + location = options[:location] + musician = options[:musician] + photo_url = options[:photo_url] + invited_user = options[:invited_user] + fb_signup = options[:fb_signup] + signup_confirm_url = options[:signup_confirm_url] @user = User.new @@ -33,8 +47,20 @@ class UserManager < BaseManager # 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, terms_of_service, - location, instruments, birth_date, musician, photo_url, invited_user, signup_confirm_url) + @user = User.signup(first_name: first_name, + last_name: last_name, + email: email, + password: password, + password_confirmation: password_confirmation, + terms_of_service: terms_of_service, + location: location, + instruments: instruments, + birth_date: birth_date, + musician: musician, + photo_url: photo_url, + invited_user: invited_user, + fb_signup: fb_signup, + signup_confirm_url: signup_confirm_url) return @user #end diff --git a/web/spec/controllers/sessions_controller_spec.rb b/web/spec/controllers/sessions_controller_spec.rb index f0de20a45..4c0456aa0 100644 --- a/web/spec/controllers/sessions_controller_spec.rb +++ b/web/spec/controllers/sessions_controller_spec.rb @@ -70,18 +70,6 @@ describe SessionsController do visit '/auth/facebook' end.should change(User, :count).by(0) end - - - it "should not create a user when oauth comes in with a currently existing user" do - user = FactoryGirl.create(:user) # in the jam session - OmniAuth.config.mock_auth[:facebook][:info][:email] = user.email - OmniAuth.config.mock_auth[:facebook] = OmniAuth.config.mock_auth[:facebook] - - lambda do - visit '/auth/facebook' - end.should change(User, :count).by(0) - end - end diff --git a/web/spec/factories.rb b/web/spec/factories.rb index 0cc98df63..0c359d05a 100644 --- a/web/spec/factories.rb +++ b/web/spec/factories.rb @@ -308,5 +308,14 @@ FactoryGirl.define do association :authentication, :factory => :icecast_user_authentication end - + factory :facebook_signup, :class => JamRuby::FacebookSignup do + sequence(:lookup_id) { |n| "lookup-#{n}"} + sequence(:first_name) { |n| "first-#{n}"} + sequence(:last_name) { |n| "last-#{n}"} + gender 'M' + sequence(:email) { |n| "jammin-#{n}@jamkazam.com"} + sequence(:uid) { |n| "uid-#{n}"} + sequence(:token) { |n| "token-#{n}"} + token_expires_at Time.now + end end diff --git a/web/spec/features/signup_spec.rb b/web/spec/features/signup_spec.rb index 2cf59a348..43bf5049e 100644 --- a/web/spec/features/signup_spec.rb +++ b/web/spec/features/signup_spec.rb @@ -83,9 +83,12 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do before do @invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com") visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" + find('#jam_ruby_user_first_name') + sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out UserMailer.deliveries.clear - fill_in "jam_ruby_user[first_name]", with: "Mike" + + fill_in "jam_ruby_user[first_name]", with: "Mike" fill_in "jam_ruby_user[last_name]", with: "Jones" fill_in "jam_ruby_user[email]", with: "newuser2@jamkazam.com" fill_in "jam_ruby_user[password]", with: "jam123" @@ -110,6 +113,8 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do @user = FactoryGirl.create(:user) @invited_user = FactoryGirl.create(:invited_user, :sender => @user, :autofriend => true, :email => "noone@jamkazam.com") visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" + find('#jam_ruby_user_first_name') + sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out fill_in "jam_ruby_user[first_name]", with: "Mike" fill_in "jam_ruby_user[last_name]", with: "Jones" @@ -136,6 +141,8 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do before do @invited_user = FactoryGirl.create(:invited_user, :email => "noone@jamkazam.com") visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" + find('#jam_ruby_user_first_name') + sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out fill_in "jam_ruby_user[first_name]", with: "Mike" fill_in "jam_ruby_user[last_name]", with: "Jones" @@ -159,6 +166,8 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do before do @invited_user = FactoryGirl.create(:invited_user, :email => "what@jamkazam.com") visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" + find('#jam_ruby_user_first_name') + sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out UserMailer.deliveries.clear diff --git a/web/spec/features/welcome_spec.rb b/web/spec/features/welcome_spec.rb new file mode 100644 index 000000000..02eb1c263 --- /dev/null +++ b/web/spec/features/welcome_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe "Welcome", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + before(:all) do + Capybara.javascript_driver = :poltergeist + Capybara.current_driver = Capybara.javascript_driver + Capybara.default_wait_time = 10 + end + + before(:each) do + page.driver.headers = { 'User-Agent' => ' JamKazam ' } + visit "/" + find('h1', text: 'Play music together over the Internet as if in the same room') + + end + + let(:user) { FactoryGirl.create(:user) } + + describe "signup" do + + before(:each) do + find('#signup').trigger(:click) + end + + it "show dialog" do + should have_selector('h1', text: 'sign up for jamkazam') + end + + describe "signup with email" do + + it "click will redirect to signup page" do + find('.signup-email').trigger(:click) + find('h2', text: 'Create a JamKazam account') + end + end + + # this works becuause OmniAuth.config_mode.test = true + describe "signup with facebook" do + + + before(:each) do + + OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({ + :provider => "facebook", + :uid => "1234", + :info => {:name => "John Doe", + :email => "johndoe@email.com"}, + :credentials => {:token => "testtoken234tsdf", :expires_at => 2391456019}, + :extra => { :raw_info => {:first_name => 'John', :last_name => 'Doe', :email => 'facebook@jamkazam.com', :gender => 'male'}} }) + end + + it "click will redirect to facebook for authorization" do + find('.signup-facebook').trigger(:click) + find('h2', text: 'Create a JamKazam account') + find_field('jam_ruby_user[first_name]').value.should eq 'John' + find_field('jam_ruby_user[last_name]').value.should eq 'Doe' + find_field('jam_ruby_user[email]').value.should eq 'facebook@jamkazam.com' + end + end + + end +end + diff --git a/web/spec/managers/user_manager_spec.rb b/web/spec/managers/user_manager_spec.rb index 89d501ebe..85dec168f 100644 --- a/web/spec/managers/user_manager_spec.rb +++ b/web/spec/managers/user_manager_spec.rb @@ -15,7 +15,16 @@ describe UserManager do MaxMindIsp.delete_all # prove that city/state/country will remain nil if no maxmind data MaxMindGeo.delete_all - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman1@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman1@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician:true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.first_name.should == "bob" @@ -33,8 +42,16 @@ describe UserManager do end it "signup successfully with instruments" do - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman2@jamkazam.com", "foobar", "foobar", true, - @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman2@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") @user.errors.any?.should be_false @user.instruments.length.should == 1 @@ -44,7 +61,15 @@ describe UserManager do end it "doesnt fail if ip address is nil" do - @user = @user_manager.signup(nil, "bob", "smith", "userman3@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(first_name: "bob", + last_name: "smith", + email: "userman3@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.city.should be_nil @@ -56,7 +81,16 @@ describe UserManager do MaxMindManager.active_record_transaction do |manager| manager.create_phony_database() end - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman4@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman4@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.city.should == 'City 127' @@ -68,7 +102,17 @@ describe UserManager do MaxMindManager.active_record_transaction do |manager| manager.create_phony_database() end - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman5@jamkazam.com", "foobar", "foobar", true, @instruments, nil, @location, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman5@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + location: @location, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.city.should == 'Little Rock' @@ -80,7 +124,17 @@ describe UserManager do MaxMindManager.active_record_transaction do |manager| manager.create_phony_database() end - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman6@jamkazam.com", "foobar", "foobar", true, @instruments, nil, {}, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman6@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + location: {}, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.city.should be_nil @@ -93,7 +147,17 @@ describe UserManager do MaxMindManager.active_record_transaction do |manager| manager.create_phony_database() end - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman7@jamkazam.com", "foobar", "foobar", true, @instruments, Date.new(2001, 1, 1), nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman7@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + birth_date: Date.new(2001, 1, 1), + musician: true, + signup_confirm_url: "http://localhost:3000/confirm" ) @user.errors.any?.should be_false @user.birth_date.should == Date.new(2001, 1, 1) @@ -101,26 +165,64 @@ describe UserManager do it "duplicate signup failure" do - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman8@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman8@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") + UserMailer.deliveries.length.should == 1 @user.errors.any?.should be_false # exactly the same parameters; should dup on email, and send no email - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman8@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman8@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") UserMailer.deliveries.length.should == 1 @user.errors.any?.should be_true @user.errors[:email][0].should == "has already been taken" end - it "fail on no username" do - @user = @user_manager.signup("127.0.0.1", "", "", "userman10@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm") + it "fail on no first_name/last_name" do + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "", + last_name: "", + email: "userman10@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") UserMailer.deliveries.length.should == 0 @user.errors.any?.should be_true @user.errors[:first_name][0].should == "can't be blank" end it "fail on no email" do - @user = @user_manager.signup("127.0.0.1", "murp", "blurp", "", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "murp", + last_name: "blurp", + email: "", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") + UserMailer.deliveries.length.should == 0 @user.errors.any?.should be_true @user.errors[:email][0].should == "can't be blank" @@ -130,7 +232,16 @@ describe UserManager do describe "signup_confirm" do it "fail on no username" do - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman11@jamkazam.com", "foobar", "foobar", true, @instruments, nil, nil, true, nil, nil, "http://localhost:3000/confirm" ) + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman11@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + signup_confirm_url: "http://localhost:3000/confirm") @user = @user_manager.signup_confirm(@user.signup_token) @user.email_confirmed.should be_true end @@ -156,8 +267,17 @@ describe UserManager do @invitation.accepted.should be_false - @user = @user_manager.signup("127.0.0.1", "bob", "smith", @invitation.email, "foobar", "foobar", true, - @instruments, nil, nil, true, nil, @invitation, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: @invitation.email, + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + invited_user: @invitation, + signup_confirm_url: "http://localhost:3000/confirm") @user.errors.any?.should be_false @user.email_confirmed.should be_true @@ -176,8 +296,17 @@ describe UserManager do UserMailer.deliveries.clear - @user = @user_manager.signup("127.0.0.1", "bob", "smith", @invitation.email, "foobar", "foobar", true, - @instruments, nil, nil, true, nil, @invitation, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: @invitation.email, + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + invited_user: @invitation, + signup_confirm_url: "http://localhost:3000/confirm") @user.errors.any?.should be_false @user.email_confirmed.should be_true @@ -196,8 +325,17 @@ describe UserManager do UserMailer.deliveries.clear - @user = @user_manager.signup("127.0.0.1", "bob", "smith", @invitation.email, "foobar", "foobar", true, - @instruments, nil, nil, true, nil, @invitation, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: @invitation.email, + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + invited_user: @invitation, + signup_confirm_url: "http://localhost:3000/confirm") @user.errors.any?.should be_false @user.email_confirmed.should be_true @@ -218,8 +356,17 @@ describe UserManager do UserMailer.deliveries.clear - @user = @user_manager.signup("127.0.0.1", "bob", "smith", "userman12@jamkazam.com", "foobar", "foobar", true, - @instruments, nil, nil, true, nil, @invitation, "http://localhost:3000/confirm") + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman12@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + invited_user: @invitation, + signup_confirm_url: "http://localhost:3000/confirm") @user.errors.any?.should be_false @user.email_confirmed.should be_false @@ -229,6 +376,91 @@ describe UserManager do @user.friends?(@some_user).should be_true @user.friends?(@some_user).should be_true - UserMailer.deliveries.length.should == 1 # no emails should be sent, in this case + UserMailer.deliveries.length.should == 1 + end + + it "signup successfully with facebook signup additional info" do + fb_signup = FactoryGirl.create(:facebook_signup) + + UserMailer.deliveries.clear + + + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: fb_signup.email, + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + fb_signup: fb_signup, + signup_confirm_url: "http://localhost:3000/confirm") + + @user.errors.any?.should be_false + @user.email_confirmed.should be_true + @user.signup_token.should be_nil + @user.user_authorizations.length.should == 1 + @user.user_authorizations[0].uid = fb_signup.uid + @user.user_authorizations[0].token = fb_signup.token + @user.user_authorizations[0].token_expiration = fb_signup.token_expires_at + + UserMailer.deliveries.length.should == 1 + end + + it "signup successfully with facebook signup additional info, but different email" do + fb_signup = FactoryGirl.create(:facebook_signup) + + UserMailer.deliveries.clear + + + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman13@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + fb_signup: fb_signup, + signup_confirm_url: "http://localhost:3000/confirm") + + @user.errors.any?.should be_false + @user.email_confirmed.should be_false + @user.signup_token.should_not be_nil + @user.user_authorizations.length.should == 1 + @user.user_authorizations[0].uid = fb_signup.uid + @user.user_authorizations[0].token = fb_signup.token + @user.user_authorizations[0].token_expiration = fb_signup.token_expires_at + + UserMailer.deliveries.length.should == 1 + end + + it "fail to signup when facebook UID already taken" do + fb_signup = FactoryGirl.create(:facebook_signup) + + @some_user = FactoryGirl.create(:user) + @some_user.update_fb_authorization(fb_signup) + @some_user.save! + + UserMailer.deliveries.clear + + @user = @user_manager.signup(remote_ip: "127.0.0.1", + first_name: "bob", + last_name: "smith", + email: "userman13@jamkazam.com", + password: "foobar", + password_confirmation: "foobar", + terms_of_service: true, + instruments: @instruments, + musician: true, + fb_signup: fb_signup, + signup_confirm_url: "http://localhost:3000/confirm") + + @user.errors.any?.should be_true + @user.errors[:user_authorizations].should == ['is invalid'] + + UserMailer.deliveries.length.should == 0 end end diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 5dcd63570..8dbb93069 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -1,5 +1,6 @@ require 'rubygems' require 'spork' +require 'omniauth' #uncomment the following line to use spork with the debugger #require 'spork/ext/ruby-debug' @@ -25,6 +26,8 @@ include JamRuby # put ActionMailer into test mode ActionMailer::Base.delivery_method = :test + + Spork.prefork do # Loading more in this block will cause your tests to run faster. However, # if you change any configuration or code from libraries loaded here, you'll From d10f966c0be462aa269bf21449abc827f92f3e7b Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 3 Feb 2014 21:19:34 +0000 Subject: [PATCH 02/21] * VRFS-1025 finished --- .../images/content/button_facebook_signin.png | Bin 0 -> 6583 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 web/app/assets/images/content/button_facebook_signin.png diff --git a/web/app/assets/images/content/button_facebook_signin.png b/web/app/assets/images/content/button_facebook_signin.png new file mode 100644 index 0000000000000000000000000000000000000000..08b15b7ba18938096e7b5fa9547b927d02d928c2 GIT binary patch literal 6583 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 Hw2k~9WN0Vf literal 0 HcmV?d00001 From d82b0b6fd92f4e3ea3ff987b756ec720be4960e0 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 02:45:52 +0000 Subject: [PATCH 03/21] * VRFS-1026 - putting user dropdown back to where it belonged --- web/app/assets/javascripts/jam_rest.js | 14 +++ .../assets/javascripts/web/signinDialog.js | 56 ++++++++- .../assets/javascripts/web/signupDialog.js | 6 + .../stylesheets/client/content.css.scss | 18 +-- .../stylesheets/client/user_dropdown.css.scss | 1 - .../stylesheets/users/signinDialog.css.scss | 56 +++++++++ web/app/assets/stylesheets/web/web.css | 1 + web/app/controllers/api_auths_controller.rb | 22 ++++ .../controllers/api_sessions_controller.rb | 20 ++++ web/app/controllers/clients_controller.rb | 2 +- web/app/controllers/users_controller.rb | 2 + web/app/views/users/_signinDialog.html.erb | 61 +++++----- web/app/views/users/_signupDialog.html.erb | 2 +- web/config/routes.rb | 3 + web/spec/features/welcome_spec.rb | 106 ++++++++++++++++-- 15 files changed, 313 insertions(+), 57 deletions(-) create mode 100644 web/app/assets/stylesheets/users/signinDialog.css.scss create mode 100644 web/app/controllers/api_auths_controller.rb create mode 100644 web/app/controllers/api_sessions_controller.rb diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 9b2235032..86e7c6344 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -189,6 +189,19 @@ }); } + function login(options) { + var url = '/api/auths/login'; + + return $.ajax({ + type: "POST", + dataType: "json", + url: url, + processData: false, + contentType: 'application/json', + data: JSON.stringify(options) + }); + } + function getUserDetail(options) { var id = getId(options); @@ -793,6 +806,7 @@ this.createBandInvitation = createBandInvitation; this.updateBandInvitation = updateBandInvitation; this.removeBandMember = removeBandMember; + this.login = login; return this; }; diff --git a/web/app/assets/javascripts/web/signinDialog.js b/web/app/assets/javascripts/web/signinDialog.js index aded10b15..5d1f4e989 100644 --- a/web/app/assets/javascripts/web/signinDialog.js +++ b/web/app/assets/javascripts/web/signinDialog.js @@ -9,16 +9,60 @@ var rest = context.JK.Rest(); var dialogId = '#signin-dialog'; + function reset() { + $(dialogId + ' #signin-form').removeClass('login-error') + + $(dialogId + ' input[name=email]').val(''); + $(dialogId + ' input[name=password]').val(''); + $(dialogId + ' input[name=remember_me]').attr('checked', 'checked') + } + + function login() { + var email = $(dialogId + ' input[name=email]').val(); + var password = $(dialogId + ' input[name=password]').val(); + var rememberMe = $(dialogId + ' input[name=remember_me]').is(':checked') + + rest.login({email: email, password: password, remember_me: rememberMe}) + .done(function() { + app.layout.closeDialog('signin-dialog') + window.location = '/client' + }) + .fail(function(jqXHR) { + if(jqXHR.status == 422) { + $(dialogId + ' #signin-form').addClass('login-error') + } + else { + app.notifyServerError(jqXHR, "Unable to log in") + } + }) + } + function events() { - $(dialogId + ' .signin-cancel').click(function(e) { - app.layout.closeDialog('signin-dialog'); - e.stopPropagation(); - return false; - }); + $(dialogId + ' .signin-cancel').click(function(e) { + app.layout.closeDialog('signin-dialog'); + e.stopPropagation(); + return false; + }); + + $(dialogId + ' #signin-form').submit(function(e) { + login(); + return false; + }); + + $(dialogId + ' .signin-submit').click(function(e) { + login(); + return false; + }); + + $(dialogId + ' .show-signup-dialog').click(function(e) { + app.layout.closeDialog('signin-dialog') + app.layout.showDialog('signup-dialog') + return false; + }) } function beforeShow() { - + reset(); } function afterHide() { diff --git a/web/app/assets/javascripts/web/signupDialog.js b/web/app/assets/javascripts/web/signupDialog.js index 2c85ac2f7..fc126cb57 100644 --- a/web/app/assets/javascripts/web/signupDialog.js +++ b/web/app/assets/javascripts/web/signupDialog.js @@ -15,6 +15,12 @@ e.stopPropagation(); return false; }); + + $(dialogId + ' .show-signin-dialog').click(function(e) { + app.layout.closeDialog('signup-dialog') + app.layout.showDialog('signin-dialog') + return false; + }) } function beforeShow() { diff --git a/web/app/assets/stylesheets/client/content.css.scss b/web/app/assets/stylesheets/client/content.css.scss index a7a4d6584..807a4ae93 100644 --- a/web/app/assets/stylesheets/client/content.css.scss +++ b/web/app/assets/stylesheets/client/content.css.scss @@ -190,13 +190,17 @@ font-size:24px; } -.content-wrapper select, .content-wrapper textarea, .content-wrapper input[type=text], .content-wrapper input[type=password], div.friendbox, .ftue-inner input[type=text], .ftue-inner input[type=password], .dialog-inner textarea, .dialog-inner input[type=text], .dialog-inner select { - font-family:"Raleway", arial, sans-serif; - background-color:#c5c5c5; - border:none; - -webkit-box-shadow: inset 2px 2px 3px 0px #888; - box-shadow: inset 2px 2px 3px 0px #888; - color:#666; +.content-wrapper, .dialog, .dialog-inner, .ftue-inner { + + select, textarea, input[type=text], input[type=password], div.friendbox { + font-family:"Raleway", arial, sans-serif; + background-color:#c5c5c5; + border:none; + -webkit-box-shadow: inset 2px 2px 3px 0px #888; + box-shadow: inset 2px 2px 3px 0px #888; + color:#666; + } + } .create-session-description { diff --git a/web/app/assets/stylesheets/client/user_dropdown.css.scss b/web/app/assets/stylesheets/client/user_dropdown.css.scss index 42e8081af..79096c8b8 100644 --- a/web/app/assets/stylesheets/client/user_dropdown.css.scss +++ b/web/app/assets/stylesheets/client/user_dropdown.css.scss @@ -9,7 +9,6 @@ #profile { float: right; height: 54px; - margin-top: 30px; text-align: right; ul { diff --git a/web/app/assets/stylesheets/users/signinDialog.css.scss b/web/app/assets/stylesheets/users/signinDialog.css.scss new file mode 100644 index 000000000..3bcb8cc63 --- /dev/null +++ b/web/app/assets/stylesheets/users/signinDialog.css.scss @@ -0,0 +1,56 @@ +#signin-dialog { + height:auto; +} + +#signin-dialog { + + div.field { + width:100%; + } + + div.overlay-inner { + height:auto; + } + + label { + margin-bottom:2px; + } + + div.email { + margin-top:5px; + } + + div.password { + margin-top:20px; + } + + div.actions { + margin-top:20px; + } + + .login-error { + background-color: #330000; + border: 1px solid #990000; + padding:4px; + + div.actions { + margin-top:10px; + } + } + + .login-error-msg { + display:none; + margin-top:10px; + text-align:center; + color:#F00; + font-size:11px; + } + + .login-error .login-error-msg { + display:block; + } + + input[type=text], input[type=password]{ + box-sizing: border-box; + } +} \ No newline at end of file diff --git a/web/app/assets/stylesheets/web/web.css b/web/app/assets/stylesheets/web/web.css index 98e7bd256..de27dc5bc 100644 --- a/web/app/assets/stylesheets/web/web.css +++ b/web/app/assets/stylesheets/web/web.css @@ -13,4 +13,5 @@ *= require web/recordings *= require web/welcome #= require web/sessions +*= require users/signinDialog */ \ No newline at end of file diff --git a/web/app/controllers/api_auths_controller.rb b/web/app/controllers/api_auths_controller.rb new file mode 100644 index 000000000..00001a7e4 --- /dev/null +++ b/web/app/controllers/api_auths_controller.rb @@ -0,0 +1,22 @@ +class ApiAuthsController < ApiController + + respond_to :json + + def login + user = User.authenticate(params[:email], params[:password]) + + if user.nil? + render :json => {}, :status => 422 + else + if jkclient_agent? + user.update_progression_field(:first_ran_client_at) + end + + @session_only_cookie = !jkclient_agent? && !params[:remember_me] + + sign_in user + + render :json => {}, :status => :ok + end + end +end diff --git a/web/app/controllers/api_sessions_controller.rb b/web/app/controllers/api_sessions_controller.rb new file mode 100644 index 000000000..b2f860747 --- /dev/null +++ b/web/app/controllers/api_sessions_controller.rb @@ -0,0 +1,20 @@ +class ApiSearchController < ApiController + + def login + user = User.authenticate(params[:email], params[:password]) + + if user.nil? + render :json => {}, :status => 422 + else + if jkclient_agent? + user.update_progression_field(:first_ran_client_at) + end + + @session_only_cookie = !jkclient_agent? && 0 == params[:remember_me].to_i + + sign_in user + + render :json => {}, :status => :ok + end + end +end diff --git a/web/app/controllers/clients_controller.rb b/web/app/controllers/clients_controller.rb index 009256e40..d8dde3f7a 100644 --- a/web/app/controllers/clients_controller.rb +++ b/web/app/controllers/clients_controller.rb @@ -35,7 +35,7 @@ class ClientsController < ApplicationController if current_user render :layout => 'client' else - redirect_to "/signin" + redirect_to root_url end end diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index 6c98a031d..770f3ca15 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -133,6 +133,8 @@ class UsersController < ApplicationController terms_of_service = params[:jam_ruby_user][:terms_of_service].nil? ? false : true musician = params[:jam_ruby_user][:musician] + puts "params: #{params.inspect}" + @user = UserManager.new.signup(remote_ip: request.remote_ip, first_name: params[:jam_ruby_user][:first_name], last_name: params[:jam_ruby_user][:last_name], diff --git a/web/app/views/users/_signinDialog.html.erb b/web/app/views/users/_signinDialog.html.erb index 9dc8df8a0..b14733178 100644 --- a/web/app/views/users/_signinDialog.html.erb +++ b/web/app/views/users/_signinDialog.html.erb @@ -8,7 +8,7 @@
- <%= link_to image_tag("content/button_facebook_signin.png", {:width => 249, :height => 46 }), '/auth/facebook', class: "signin-facebook" %> + <%= link_to image_tag("content/button_facebook_signin.png", {:width => 249, :height => 46}), '/auth/facebook', class: "signin-facebook" %>

@@ -17,42 +17,43 @@

-
- - - - - - - - + - - - - -
Email Address:
-

-
Password:
-
- Keep me signed in -

+ + +
+ + +
+ + + Keep me signed in + + + +
+ +
+ +    +
+
+ Forgot Password? +
- -
-
- Don't have an account? Sign Up + Don't have an account?
+
+
-
\ No newline at end of file +
+ diff --git a/web/app/views/users/_signupDialog.html.erb b/web/app/views/users/_signupDialog.html.erb index 6b19e7b1e..66d6fea7f 100644 --- a/web/app/views/users/_signupDialog.html.erb +++ b/web/app/views/users/_signupDialog.html.erb @@ -21,7 +21,7 @@
- Already have an account?
+ Already have an account?

diff --git a/web/config/routes.rb b/web/config/routes.rb index 4c5556626..41b3a003c 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -94,6 +94,9 @@ SampleApp::Application.routes.draw do end scope '/api' do + + match '/auths/login' => 'api_auths#login', :via => :post + # music sessions match '/sessions/:id/participants' => 'api_music_sessions#participant_create', :via => :post match '/participants/:id' => 'api_music_sessions#participant_show', :via => :get, :as => 'api_session_participant_detail' diff --git a/web/spec/features/welcome_spec.rb b/web/spec/features/welcome_spec.rb index 02eb1c263..8fa2f131b 100644 --- a/web/spec/features/welcome_spec.rb +++ b/web/spec/features/welcome_spec.rb @@ -18,6 +18,87 @@ describe "Welcome", :js => true, :type => :feature, :capybara_feature => true d end let(:user) { FactoryGirl.create(:user) } + let(:fb_auth) { + { :provider => "facebook", + :uid => "1234", + :info => {:name => "John Doe", + :email => "johndoe@email.com"}, + :credentials => {:token => "testtoken234tsdf", :expires_at => 2391456019}, + :extra => { :raw_info => {:first_name => 'John', :last_name => 'Doe', :email => 'facebook@jamkazam.com', :gender => 'male'}} } + } + + describe "signin" do + before(:each) do + find('#signin').trigger(:click) + end + + it "show dialog" do + should have_selector('h1', text: 'sign in') + end + + it "shows signup dialog if selected" do + find('.show-signup-dialog').trigger(:click) + + find('h1', text: 'sign up for jamkazam') + end + + it "forgot password" do + find('a.forgot-password').trigger(:click) + + find('h1', text: 'reset your password') + end + + it "closes if cancelled" do + find('a.signin-cancel').trigger(:click) + + should_not have_selector('h1', text: 'sign in') + end + + describe "signin natively" do + + it "redirects to client on login" do + within('#signin-form') do + fill_in "email", with: user.email + fill_in "password", with: user.password + click_button "SIGN IN" + end + + wait_until_curtain_gone + + find('h2', text: 'musicians') + end + + it "shows error if bad login" do + within('#signin-form') do + fill_in "email", with: "junk" + fill_in "password", with: user.password + click_button "SIGN IN" + end + + should have_selector('h1', text: 'sign in') + + find('div.login-error-msg', text: 'Invalid login') + end + end + + describe "signin with facebook" do + + before(:each) do + user.user_authorizations.build provider: 'facebook', uid: '1234', token: 'abc', token_expiration: 1.days.from_now + user.save! + OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(fb_auth) + end + + it "click will redirect to facebook for authorization" do + find('.signin-facebook').trigger(:click) + + wait_until_curtain_gone + + find('h2', text: 'musicians') + end + end + + end describe "signup" do @@ -29,6 +110,18 @@ describe "Welcome", :js => true, :type => :feature, :capybara_feature => true d should have_selector('h1', text: 'sign up for jamkazam') end + it "shows signin dialog if selected" do + find('.show-signin-dialog').trigger(:click) + + find('h1', text: 'sign in') + end + + it "closes if cancelled" do + find('a.signup-cancel').trigger(:click) + + should_not have_selector('h1', text: 'sign in') + end + describe "signup with email" do it "click will redirect to signup page" do @@ -37,19 +130,11 @@ describe "Welcome", :js => true, :type => :feature, :capybara_feature => true d end end - # this works becuause OmniAuth.config_mode.test = true describe "signup with facebook" do - before(:each) do - - OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({ - :provider => "facebook", - :uid => "1234", - :info => {:name => "John Doe", - :email => "johndoe@email.com"}, - :credentials => {:token => "testtoken234tsdf", :expires_at => 2391456019}, - :extra => { :raw_info => {:first_name => 'John', :last_name => 'Doe', :email => 'facebook@jamkazam.com', :gender => 'male'}} }) + fb_auth[:uid] = '12345' + OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(fb_auth) end it "click will redirect to facebook for authorization" do @@ -60,7 +145,6 @@ describe "Welcome", :js => true, :type => :feature, :capybara_feature => true d find_field('jam_ruby_user[email]').value.should eq 'facebook@jamkazam.com' end end - end end From ea19fe002d7358834f50e76e9433c93eecee2758 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 03:06:46 +0000 Subject: [PATCH 04/21] * VRFS-1026 and VRFS-1024 resolved (signin and dropdown scooted back --- web/app/controllers/users_controller.rb | 2 -- web/spec/features/authentication_pages_spec.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index 770f3ca15..6c98a031d 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -133,8 +133,6 @@ class UsersController < ApplicationController terms_of_service = params[:jam_ruby_user][:terms_of_service].nil? ? false : true musician = params[:jam_ruby_user][:musician] - puts "params: #{params.inspect}" - @user = UserManager.new.signup(remote_ip: request.remote_ip, first_name: params[:jam_ruby_user][:first_name], last_name: params[:jam_ruby_user][:last_name], diff --git a/web/spec/features/authentication_pages_spec.rb b/web/spec/features/authentication_pages_spec.rb index db161396d..6f2ea1ec3 100644 --- a/web/spec/features/authentication_pages_spec.rb +++ b/web/spec/features/authentication_pages_spec.rb @@ -62,7 +62,7 @@ describe "Authentication", :js => true, :type => :feature, :capybara_feature => find('.userinfo .sign-out a').trigger(:click) end - it { page.should have_title("JamKazam | Sign in") } + it { find('h1', text: 'Play music together over the Internet as if in the same room') } end end end From dc70f349b6835253bf79519e2f2263707dd4f5d1 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 03:16:39 +0000 Subject: [PATCH 05/21] * overlay-small i being pulled 150px to the left --- web/app/assets/stylesheets/client/screen_common.css.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/web/app/assets/stylesheets/client/screen_common.css.scss b/web/app/assets/stylesheets/client/screen_common.css.scss index fe9d3497b..fbc3dbdf9 100644 --- a/web/app/assets/stylesheets/client/screen_common.css.scss +++ b/web/app/assets/stylesheets/client/screen_common.css.scss @@ -353,7 +353,6 @@ small, .small {font-size:11px;} position:absolute; left:50%; top:20%; - margin-left:-150px; background-color:#333; border: 1px solid #ed3618; z-index:1000; From 3414229384a19c72a69a7b68e212d557a40dea72 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 4 Feb 2014 01:12:34 -0600 Subject: [PATCH 06/21] vrfs152: added test to allow multiple signups with a fb invite --- web/spec/features/signup_spec.rb | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/web/spec/features/signup_spec.rb b/web/spec/features/signup_spec.rb index 43bf5049e..76d064fc2 100644 --- a/web/spec/features/signup_spec.rb +++ b/web/spec/features/signup_spec.rb @@ -162,6 +162,48 @@ describe "Signup", :js => true, :type => :feature, :capybara_feature => true do end + def signup_invited_user + visit "#{signup_path}?invitation_code=#{@invited_user.invitation_code}" + find('#jam_ruby_user_first_name') + sleep 1 # if I don't do this, first_name and/or last name intermittently fail to fill out + + fill_in "jam_ruby_user[first_name]", with: "Mike" + fill_in "jam_ruby_user[last_name]", with: "Jones" + @invited_user_email = "newuser#{rand(10000)}@jamkazam.com" + fill_in "jam_ruby_user[email]", with: @invited_user_email + fill_in "jam_ruby_user[password]", with: "jam123" + fill_in "jam_ruby_user[password_confirmation]", with: "jam123" + check("jam_ruby_user[instruments][drums][selected]") + check("jam_ruby_user[terms_of_service]") + click_button "CREATE ACCOUNT" + end + + def signup_good + should have_title("JamKazam") + should have_selector('div.tagline', text: "Congratulations!") + @user.friends?(User.find_by_email(@invited_user_email)) + User.find_by_email(@invited_user_email).friends?(@user) + uri = URI.parse(current_url) + "#{uri.path}?#{uri.query}".should == congratulations_musician_path(:type => 'Native') + end + + describe "can signup with facebook link multiple times with same invite" do + before do + @user = FactoryGirl.create(:user) + @invited_user = FactoryGirl.create(:invited_user, :sender => @user, :autofriend => true, :email => "noone@jamkazam.com", :invite_medium => InvitedUser::FB_MEDIUM) + end + + # Successful sign-in goes to the client + it { + signup_invited_user + signup_good + } + it { + signup_invited_user + signup_good + } + end + describe "can signup with an email different than the one used to invite" do before do @invited_user = FactoryGirl.create(:invited_user, :email => "what@jamkazam.com") From 7797b6907c30197dca131966da49d91208380438 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Tue, 4 Feb 2014 01:16:16 -0600 Subject: [PATCH 07/21] vrfs152: added GA tracking for FB invites --- web/app/assets/javascripts/invitationDialog.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/app/assets/javascripts/invitationDialog.js b/web/app/assets/javascripts/invitationDialog.js index f268554b7..f38dec040 100644 --- a/web/app/assets/javascripts/invitationDialog.js +++ b/web/app/assets/javascripts/invitationDialog.js @@ -212,6 +212,9 @@ }; function fbFeedDialogCallback(response) { //console.log("feedback dialog closed: " + response['post_id']) + if (response['post_id']) { + context.JK.GA.trackServiceInvitations(context.JK.GA.InvitationTypes.facebook, 1); + } } FB.ui(obj, fbFeedDialogCallback); } From 5df00b28834b4e721c1307055c756c850cf02a79 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 13:48:13 +0000 Subject: [PATCH 08/21] * VRFS-1012-fixing any URLs that don't start with /client --- .../views/jam_ruby/user_mailer/new_musicians.html.erb | 2 +- .../views/jam_ruby/user_mailer/new_musicians.text.erb | 2 +- web/app/assets/javascripts/bandProfile.js | 11 +++++++++-- web/app/assets/javascripts/findBand.js | 4 ++-- web/app/assets/javascripts/findMusician.js | 6 +++--- web/app/assets/javascripts/homeScreen.js | 2 +- web/app/assets/javascripts/searchResults.js | 6 +++--- web/app/assets/javascripts/sessionList.js | 2 +- 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.html.erb index a6abfd81a..d5c91c673 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.html.erb @@ -13,7 +13,7 @@ <% end %> <%= user.biography %>

-Profile   +Profile   diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.text.erb index c69f9965f..13e391154 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians.text.erb @@ -1,7 +1,7 @@ New JamKazam Musicians in your Area <% @new_nearby.each do |user| %> -<%= user.name %> (http://<%= @host %>/#/profile/<%= user.id %>) +<%= user.name %> (http://<%= @host %>/client#/profile/<%= user.id %>) <%= user.location %> <% user.instruments.collect { |inst| inst.description }.join(', ') %> <%= user.biography %> diff --git a/web/app/assets/javascripts/bandProfile.js b/web/app/assets/javascripts/bandProfile.js index 7551163e3..8cae06e1b 100644 --- a/web/app/assets/javascripts/bandProfile.js +++ b/web/app/assets/javascripts/bandProfile.js @@ -152,12 +152,14 @@ $('#btn-follow-band').text('STOP FOLLOWING'); $('#btn-follow-band').click(function() { removeFollowing(true, bandId); + return false; }); } else { $('#btn-follow-band').text('FOLLOW'); $('#btn-follow-band').click(function() { addFollowing(true, bandId); + return false; }); } } @@ -176,12 +178,14 @@ $btnFollowMember.text('UN-FOLLOW'); $btnFollowMember.click(function() { removeFollowing(false, userId); + return false; }); } else { $btnFollowMember.text('FOLLOW'); $btnFollowMember.click(function() { addFollowing(false, userId); + return false; }); } } @@ -385,7 +389,7 @@ var template = $('#template-band-profile-members').html(); var memberHtml = context.JK.fillTemplate(template, { userId: musician.id, - profile_url: "/#/profile/" + musician.id, + profile_url: "/client#/profile/" + musician.id, avatar_url: context.JK.resolveAvatarUrl(musician.photo_url), name: musician.name, location: musician.location, @@ -424,6 +428,8 @@ $divMember.remove(); }) .fail(app.ajaxError); + + return false; }); } else { @@ -475,7 +481,8 @@ $("#btn-edit-band-profile").click(function() { $('div[layout-id="band/setup"] .hdn-band-id').val(bandId); - context.location = "#/band/setup"; + context.location = "/client#/band/setup"; + return false; }); } diff --git a/web/app/assets/javascripts/findBand.js b/web/app/assets/javascripts/findBand.js index 3fcfb3960..bcedec98b 100644 --- a/web/app/assets/javascripts/findBand.js +++ b/web/app/assets/javascripts/findBand.js @@ -106,7 +106,7 @@ playerVals = { player_name: aPlayer.name, - profile_url: '/#/profile/' + aPlayer.user_id, + profile_url: '/client#/profile/' + aPlayer.user_id, avatar_url: context.JK.resolveAvatarUrl(aPlayer.photo_url), player_instruments: player_instrs }; @@ -126,7 +126,7 @@ bVals = { avatar_url: context.JK.resolveAvatarUrl(bb.photo_url), - profile_url: "/#/profile/" + bb.id, + profile_url: "/client#/profile/" + bb.id, band_name: bb.name, band_location: bb.city + ', ' + bb.state, genres: bgenres, diff --git a/web/app/assets/javascripts/findMusician.js b/web/app/assets/javascripts/findMusician.js index 91ecca218..9293852c9 100644 --- a/web/app/assets/javascripts/findMusician.js +++ b/web/app/assets/javascripts/findMusician.js @@ -106,14 +106,14 @@ aFollow = mm['followings'][jj]; followVals = { musician_name: aFollow.name, - profile_url: '/#/profile/' + aFollow.user_id, + profile_url: '/client#/profile/' + aFollow.user_id, avatar_url: context.JK.resolveAvatarUrl(aFollow.photo_url), }; follows += context.JK.fillTemplate(fTemplate, followVals); if (2 == jj) break; } var actionVals = { - profile_url: "/#/profile/" + mm.id, + profile_url: "/client#/profile/" + mm.id, friend_class: 'button-' + (mm['is_friend'] ? 'grey' : 'orange'), friend_caption: (mm.is_friend ? 'DIS':'')+'CONNECT', follow_class: 'button-' + (mm['is_following'] ? 'grey' : 'orange'), @@ -124,7 +124,7 @@ mVals = { avatar_url: context.JK.resolveAvatarUrl(mm.photo_url), - profile_url: "/#/profile/" + mm.id, + profile_url: "/client#/profile/" + mm.id, musician_name: mm.name, musician_location: mm.city + ', ' + mm.state, instruments: instr_logos, diff --git a/web/app/assets/javascripts/homeScreen.js b/web/app/assets/javascripts/homeScreen.js index 9f94bc624..fd6d58ec9 100644 --- a/web/app/assets/javascripts/homeScreen.js +++ b/web/app/assets/javascripts/homeScreen.js @@ -88,7 +88,7 @@ events(); $('.profile').on('click', function() { - context.location = '#/profile/' + context.JK.currentUserId; + context.location = '/client#/profile/' + context.JK.currentUserId; }); }; diff --git a/web/app/assets/javascripts/searchResults.js b/web/app/assets/javascripts/searchResults.js index ad14a5d84..7795f4076 100644 --- a/web/app/assets/javascripts/searchResults.js +++ b/web/app/assets/javascripts/searchResults.js @@ -91,7 +91,7 @@ var args = { userId: val.id, avatar_url: context.JK.resolveAvatarUrl(val.photo_url), - profile_url: "/#/profile/" + val.id, + profile_url: "/client#/profile/" + val.id, userName: val.name, location: val.location, instruments: getInstrumentHtml(val.instruments) @@ -104,7 +104,7 @@ var invitationSentHtml = context.JK.fillTemplate($(selector).html(), { userId: val.id, first_name: val.first_name, - profile_url: "/#/profile/" + val.id + profile_url: "/client#/profile/" + val.id }); selector = isSidebar ? '#sidebar-search-results' : '#search-results'; @@ -154,7 +154,7 @@ var searchResultHtml = context.JK.fillTemplate($(template_name).html(), { userId: val.id, avatar_url: context.JK.resolveAvatarUrl(val.photo_url), - profile_url: "/#/profile/" + val.id, + profile_url: "/client#/profile/" + val.id, userName: val.name, location: val.location }); diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index 95ac0cde9..0a3fc572f 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -93,7 +93,7 @@ var photoUrl = context.JK.resolveAvatarUrl(participant.user.photo_url); var musicianVals = { avatar_url: photoUrl, - profile_url: "/#/profile/" + id, + profile_url: "/client#/profile/" + id, musician_name: name, instruments: instrumentLogoHtml }; From c3a51989fd6f7efd35fb49d7b61e9b6643ebc73c Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 14:40:05 +0000 Subject: [PATCH 09/21] * changing to localhost:3000 instead of jamkazamdev.local --- ruby/lib/jam_ruby/models/invited_user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/lib/jam_ruby/models/invited_user.rb b/ruby/lib/jam_ruby/models/invited_user.rb index 228fc024f..cebc0d25e 100644 --- a/ruby/lib/jam_ruby/models/invited_user.rb +++ b/ruby/lib/jam_ruby/models/invited_user.rb @@ -65,7 +65,7 @@ module JamRuby def generate_signup_url if 'development'==Rails.env - "http://jamkazamdev.local:3000/signup?invitation_code=#{self.invitation_code}" + "http://localhost:3000/signup?invitation_code=#{self.invitation_code}" else "http://www.jamkazam.com/signup?invitation_code=#{self.invitation_code}" end From ae8b6ebbc7a7dc40e098915bde0ad362caeb11ab Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 4 Feb 2014 17:05:38 +0000 Subject: [PATCH 10/21] * renaming all ShareDialog to ShareSessionDialog --- admin/app/controllers/artifacts_controller.rb | 12 ++++++++---- web/app/assets/javascripts/playbackControls.js | 1 + .../{shareDialog.js => shareSessionDialog.js} | 2 +- web/app/assets/javascripts/web/web.js | 2 +- web/app/assets/stylesheets/client/client.css | 2 +- ...reDialog.css.scss => shareSessionDialog.css.scss} | 0 web/app/assets/stylesheets/web/web.css | 2 +- web/app/views/clients/_session.html.erb | 2 +- ...eDialog.html.erb => _shareSessionDialog.html.erb} | 0 web/app/views/clients/index.html.erb | 4 ++-- web/app/views/music_sessions/show.html.erb | 8 ++++---- web/app/views/recordings/show.html.erb | 8 ++++---- 12 files changed, 24 insertions(+), 19 deletions(-) rename web/app/assets/javascripts/{shareDialog.js => shareSessionDialog.js} (98%) rename web/app/assets/stylesheets/client/{shareDialog.css.scss => shareSessionDialog.css.scss} (100%) rename web/app/views/clients/{_shareDialog.html.erb => _shareSessionDialog.html.erb} (100%) diff --git a/admin/app/controllers/artifacts_controller.rb b/admin/app/controllers/artifacts_controller.rb index 8e7012eff..3fb5cc5cc 100644 --- a/admin/app/controllers/artifacts_controller.rb +++ b/admin/app/controllers/artifacts_controller.rb @@ -11,12 +11,16 @@ class ArtifactsController < ApplicationController file = params[:file] environment = params[:environment] - @artifact = ArtifactUpdate.find_or_create_by_product_and_environment(product, environment) + ArtifactUpdate.transaction do + # VRFS-1071: Postpone client update notification until installer is available for download + ArtifactUpdate.connection.execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED') + @artifact = ArtifactUpdate.find_or_create_by_product_and_environment(product, environment) - @artifact.version = version - @artifact.uri = file + @artifact.version = version + @artifact.uri = file - @artifact.save + @artifact.save + end unless @artifact.errors.any? render :json => {}, :status => :ok diff --git a/web/app/assets/javascripts/playbackControls.js b/web/app/assets/javascripts/playbackControls.js index cf1df1323..1df7e6f1c 100644 --- a/web/app/assets/javascripts/playbackControls.js +++ b/web/app/assets/javascripts/playbackControls.js @@ -168,6 +168,7 @@ currentTimeMs = playbackDurationMs; stopPlay(); endReached = true; + console.log("end reached"); } else { return; diff --git a/web/app/assets/javascripts/shareDialog.js b/web/app/assets/javascripts/shareSessionDialog.js similarity index 98% rename from web/app/assets/javascripts/shareDialog.js rename to web/app/assets/javascripts/shareSessionDialog.js index dff0ce41b..24ee53d5b 100644 --- a/web/app/assets/javascripts/shareDialog.js +++ b/web/app/assets/javascripts/shareSessionDialog.js @@ -2,7 +2,7 @@ "use strict"; context.JK = context.JK || {}; - context.JK.ShareDialog = function(app) { + context.JK.ShareSessionDialog = function(app) { var logger = context.JK.logger; var rest = context.JK.Rest(); diff --git a/web/app/assets/javascripts/web/web.js b/web/app/assets/javascripts/web/web.js index ea049bbd4..03b14c5b0 100644 --- a/web/app/assets/javascripts/web/web.js +++ b/web/app/assets/javascripts/web/web.js @@ -8,7 +8,7 @@ //= require web/signupDialog //= require web/signinDialog //= require invitationDialog -//= require shareDialog +//= require shareSessionDialog //= require layout //= require user_dropdown //= require jamkazam diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index 57f1af430..a86d4cf7f 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -32,7 +32,7 @@ *= require ./search *= require ./ftue *= require ./invitationDialog - *= require ./shareDialog + *= require ./shareSessionDialog *= require ./recordingFinishedDialog *= require ./localRecordingsDialog *= require ./createSession diff --git a/web/app/assets/stylesheets/client/shareDialog.css.scss b/web/app/assets/stylesheets/client/shareSessionDialog.css.scss similarity index 100% rename from web/app/assets/stylesheets/client/shareDialog.css.scss rename to web/app/assets/stylesheets/client/shareSessionDialog.css.scss diff --git a/web/app/assets/stylesheets/web/web.css b/web/app/assets/stylesheets/web/web.css index de27dc5bc..9d047eb01 100644 --- a/web/app/assets/stylesheets/web/web.css +++ b/web/app/assets/stylesheets/web/web.css @@ -7,7 +7,7 @@ *= require client/user_dropdown *= require client/dialog *= require client/invitationDialog -*= require client/shareDialog +*= require client/shareSessionDialog *= require web/main *= require web/footer *= require web/recordings diff --git a/web/app/views/clients/_session.html.erb b/web/app/views/clients/_session.html.erb index e12b7e121..cbf3d6105 100644 --- a/web/app/views/clients/_session.html.erb +++ b/web/app/views/clients/_session.html.erb @@ -137,7 +137,7 @@ <%= render "addNewGear" %> <%= render "error" %> <%= render "sessionSettings" %> -<%= render :partial => "shareDialog" %> +<%= render :partial => "shareSessionDialog" %>