diff --git a/web/app/assets/javascripts/react-components/landing/JamClassEducationLandingPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/JamClassEducationLandingPage.js.jsx.coffee index 3a71525d6..c184f0f67 100644 --- a/web/app/assets/javascripts/react-components/landing/JamClassEducationLandingPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/JamClassEducationLandingPage.js.jsx.coffee @@ -12,7 +12,7 @@ rest = context.JK.Rest() ctaButtonText = 'hold on...' else if loggedIn - ctaButtonText = "SIGN UP" + ctaButtonText = "SET UP SCHOOL" else ctaButtonText = "SIGN UP" @@ -131,10 +131,10 @@ rest = context.JK.Rest() markTeacher: () -> - rest.updateUser({school_interest: true}) + rest.updateUser({school_interest: true,education_interest: true}) .done((response) => this.setState({done: true}) - context.location = '/client#/home' + context.location = '/client#/account/school' ) .fail((jqXHR) => this.setState({processing: false}) @@ -157,7 +157,10 @@ rest = context.JK.Rest() education_interest: true }) .done((response) => - context.location = '/client#/home' + if response.autologin + context.location = '/client#/account/school' + else + context.location = '/client#/home' ).fail((jqXHR) => @setState({processing: false}) if jqXHR.status == 422 diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index c91520df0..379288d54 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -84,6 +84,23 @@ class ApiUsersController < ApiController # recaptcha_response: params['g-recaptcha-response'] + # try to autologin , because users will try to log in via signup link + if(params[:email] && params[:password]) + test = User.authenticate(params[:email], params[:password]) + if test + @user = test + @autologin = true + @user.school_interest = !!params[:school_interest] + @user.education_interest = !!params[:education_interest] + @user.save + sign_in @user + new_user(@user, signup_hint) # sets a cookie used for GA analytics (one-time new user stuff in JavaScript) + respond_with_model(@user, new: true, location: lambda { return api_user_detail_url(@user.id) }) + return + end + end + + options = { first_name: params[:first_name], last_name: params[:last_name], @@ -187,6 +204,7 @@ class ApiUsersController < ApiController @user.is_a_student = params[:student] if params.has_key?(:student) @user.is_a_teacher = params[:teacher] if params.has_key?(:teacher) @user.school_interest = !!params[:school_interest] + @user.education_interest = !!params[:education_interest] @user.desired_package = LessonPackageType.find_by_package_type!(params[:desired_package]) if params.has_key?(:desired_package) if @user.save diff --git a/web/app/controllers/landings_controller.rb b/web/app/controllers/landings_controller.rb index 3cedf8caf..bc56cea05 100644 --- a/web/app/controllers/landings_controller.rb +++ b/web/app/controllers/landings_controller.rb @@ -402,7 +402,7 @@ class LandingsController < ApplicationController @show_approved_only = true # isn't working. totaly hack: - @school.teachers = @school.approved_teachers + @school.teachers = @school.approved_teachersL schoolRabl = Rabl::Renderer.json(@school, 'api_schools/show') @page_data = {school: @school, preview: @preview, rabl: schoolRabl} diff --git a/web/app/views/api_users/show.rabl b/web/app/views/api_users/show.rabl index 9d2bcb4b5..ca2777984 100644 --- a/web/app/views/api_users/show.rabl +++ b/web/app/views/api_users/show.rabl @@ -25,6 +25,12 @@ if @show_profile end end +if @autologin + node :autologin do + true + end +end + # give back more info if the user being fetched is yourself if current_user && @user == current_user diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index 15c440123..ffb0ecb12 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -102,7 +102,8 @@ SampleApp::Application.configure do config.time_shift_style = :sox # or sbsms config.vst_enabled = true - config.verify_email_enabled = true + config.verify_email_enabled = false config.jamclass_enabled = true config.jamblaster_menu = true + config.recaptcha_enable = false end