From 844fe3d467fca98b26fcdff25d3aba7290a0a71e Mon Sep 17 00:00:00 2001 From: Godwin Date: Wed, 1 Jun 2016 17:15:02 -0700 Subject: [PATCH] Fixed facbook login and added missing page titiles --- app/assets/stylesheets/user-mailer.scss | 3 +++ app/controllers/application_controller.rb | 13 ++++++++----- app/controllers/conferences_controller.rb | 6 +++--- app/controllers/oauths_controller.rb | 21 ++++++++------------- app/models/conference.rb | 3 ++- app/views/application/404.html.haml | 6 +----- app/views/application/_header.html.haml | 2 +- config/initializers/sorcery.rb | 9 +-------- config/locales/en.yml | 7 +++++++ 9 files changed, 34 insertions(+), 36 deletions(-) diff --git a/app/assets/stylesheets/user-mailer.scss b/app/assets/stylesheets/user-mailer.scss index 048c1fa..fdf404c 100644 --- a/app/assets/stylesheets/user-mailer.scss +++ b/app/assets/stylesheets/user-mailer.scss @@ -21,6 +21,7 @@ body { margin: 0; padding: 0; width: 100% !important; + max-width: 100% !important; line-height: 100% !important; } @@ -70,6 +71,8 @@ a { p { margin: 1em; color: $black !important; + font-size: 1.5em; + line-height: 1.3333em; } h1, h2, h3, h4, h5, h6 { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9517fc7..f9fc7bc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,17 +79,20 @@ class ApplicationController < LinguaFrancaApplicationController end def do_404 - params[:_original_action] = params[:action] - params[:action] = 'error-404' - render 'application/404', status: 404 + error_404(status: 404) end - def error_404 - render 'application/404' + def error_404(args = {}) + params[:_original_action] = params[:action] + params[:action] = 'error-404' + @page_title = 'page_titles.404.Page_Not_Found' + @main_title = 'error.404.title' + render 'application/404', args end def do_403(template = nil) @template = template + @main_title ||= @page_title params[:_original_action] = params[:action] params[:action] = 'error-403' render 'application/permission_denied', status: 403 diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 372336a..7a05555 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -529,13 +529,13 @@ class ConferencesController < ApplicationController @name ||= current_user.username @is_host = @this_conference.host? current_user - - steps = registration_steps - return do_404 unless steps.present? else @register_template = :confirm_email end + steps = registration_steps + return do_404 unless steps.present? + @errors = {} @warnings = [] form_step = params[:button] ? params[:button].to_sym : nil diff --git a/app/controllers/oauths_controller.rb b/app/controllers/oauths_controller.rb index d170844..9b411dd 100644 --- a/app/controllers/oauths_controller.rb +++ b/app/controllers/oauths_controller.rb @@ -4,11 +4,14 @@ class OauthsController < ApplicationController # sends the user on a trip to the provider, # and after authorizing there back to the callback url. def oauth + set_callback session[:oauth_last_url] = request.referer login_at(auth_params[:provider]) end def callback + set_callback + user_info = (sorcery_fetch_user_hash auth_params[:provider] || {})[:user_info] user = User.find_by_email(user_info['email']) @@ -22,19 +25,6 @@ class OauthsController < ApplicationController auto_login(user) if user redirect_to (session[:oauth_last_url] || home_path) - #, :notice => "Logged in with #{provider.titleize}!" - # if @user = login_from(provider) - # else - # begin - # @user = create_from(auth_params[:provider]) - - # reset_session - # auto_login(@user) - # redirect_to redirect_url, :notice => "Signed up with #{provider.titleize}!" - # rescue - # redirect_to redirect_url, :alert => "Failed to login with #{provider.titleize}!" - # end - # end end private @@ -42,4 +32,9 @@ class OauthsController < ApplicationController params.permit(:code, :provider) end + def set_callback + Sorcery::Controller::Config.send(params[:provider]).callback_url = + "#{request.protocol}#{request.env['HTTP_HOST']}/oauth/callback?provider=facebook" + end + end \ No newline at end of file diff --git a/app/models/conference.rb b/app/models/conference.rb index 3288d06..8950350 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -54,7 +54,8 @@ class Conference < ActiveRecord::Base end def registration_status - read_attribute(:registration_status).to_sym + s = read_attribute(:registration_status) + s.present? ? s.to_sym : nil end def registration_status=(new_registration_status) diff --git a/app/views/application/404.html.haml b/app/views/application/404.html.haml index fde5422..acbe311 100644 --- a/app/views/application/404.html.haml +++ b/app/views/application/404.html.haml @@ -1,8 +1,4 @@ -- @page_title = 'page_titles.404.Page_Not_Found' unless @page_title.present? - = render :partial => 'application/header', :locals => {:image_file => nil} = row do = columns(medium: 12) do - %h1 - =_'error.404.title','This page does not exist!' - =paragraph(_'error.404.description', :p) \ No newline at end of file + = paragraph(_'error.404.description', :p) \ No newline at end of file diff --git a/app/views/application/_header.html.haml b/app/views/application/_header.html.haml index 1c7a5e4..de3998d 100644 --- a/app/views/application/_header.html.haml +++ b/app/views/application/_header.html.haml @@ -15,4 +15,4 @@ =@page_title.present? ? I18n.t(@page_title, @page_title_vars) : I18n.t("page_titles.#{page_group.to_s}.#{page_key.to_s}") = row do = columns do - %h1=(_"page_titles.#{page_group.to_s}.#{page_key.to_s}") + %h1=_(@main_title || "page_titles.#{page_group.to_s}.#{page_key.to_s}") diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index e14b0ab..396d6ea 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -8,13 +8,6 @@ require 'openssl' OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if Rails.env.development? -ENV['bb_host'] = { - test: 'localhost:3000', - development: 'development.bikebike.org:3000', - preview: 'preview.bikebike.org', - production: 'bikebike.org', -}[Rails.env] - Rails.application.config.sorcery.submodules = [:external] # Here you can configure each submodule's features. @@ -124,7 +117,7 @@ Rails.application.config.sorcery.configure do |config| config.facebook.key = "257350517701074" config.facebook.secret = "2f6ab1fd7eeff9aee73140991fc68314" - config.facebook.callback_url = "#{ENV['bb_host']}/oauth/callback?provider=facebook" + config.facebook.callback_url = "/oauth/callback?provider=facebook" config.facebook.user_info_mapping = {:email => "email", :username => "username"} config.facebook.scope = "email" config.facebook.display = "popup" diff --git a/config/locales/en.yml b/config/locales/en.yml index cac5b4c..83c2533 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5331,6 +5331,8 @@ en: Add_Workshop: Propose a Workshop Workshops_Looking_For_Facilitators: Workshops Looking for Facilitators All_Workshops: All Workshops + Pre_Registration_Details: Pre-Registration is now open! + Verify_Account: Verify your account paragraphs: Policy_Agreement: Ensuring that all attendees feel welcome, safe, and respected at all times is especially important to us all. Please ensure that you have fully read and understand our safer spaces policy below, if you have any questions or concerns you can reach out to the organizers at any time. Confirm_Agreement: By clicking the "I Agree" button, you are pledging to do @@ -5373,6 +5375,9 @@ en: Create_Workshop: At Bike!Bike! anyone can lead a workshop or just propose and idea that someone else can volunteer to lead. If, where, and when the workshop will be scheduled will ultimately be decided by the conference organizers. Workshops_Looking_For_Facilitators: Would you like to lend a hand facilitating a workshop proposed by someone else? Below is a list of workshops that are actively looking for volunteers, if you are interested in helping out you can make a facilitation request. Your_Workshops: The following is a list of all the workshops that you have created or have requested to facilitate. + Pre_Registration_Details: By completing the pre-registration process you are letting us know that you are interested in coming, it allows us to contact you when we have news, and lets us better plan by knowing who might be coming. Once registration is fully open, we will need to ask a few more questions and you can confirm whether or not you will actually be coming. + Verify_Account: In order to confirm that you are a real person and that we will be able to contact you later, please verify your email address. Before continuing with pre-registration, we will send you an email that will allow you to continue with the process. + facebook_sign_in: Alternatively you can sign in using your Facebook account and skip waiting for us to send you an email. questions: bike: large: Large @@ -5563,6 +5568,8 @@ en: add: "+" previous: Previous next: Next + continue: Continue + facebook_sign_in: Facebook Sign In page_titles: '403': Please_Confirm_Email: Please confirm your email