Browse Source

Fixed facbook login and added missing page titiles

development
Godwin 9 years ago
parent
commit
844fe3d467
  1. 3
      app/assets/stylesheets/user-mailer.scss
  2. 13
      app/controllers/application_controller.rb
  3. 6
      app/controllers/conferences_controller.rb
  4. 21
      app/controllers/oauths_controller.rb
  5. 3
      app/models/conference.rb
  6. 6
      app/views/application/404.html.haml
  7. 2
      app/views/application/_header.html.haml
  8. 9
      config/initializers/sorcery.rb
  9. 7
      config/locales/en.yml

3
app/assets/stylesheets/user-mailer.scss

@ -21,6 +21,7 @@ body {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 100% !important; width: 100% !important;
max-width: 100% !important;
line-height: 100% !important; line-height: 100% !important;
} }
@ -70,6 +71,8 @@ a {
p { p {
margin: 1em; margin: 1em;
color: $black !important; color: $black !important;
font-size: 1.5em;
line-height: 1.3333em;
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {

13
app/controllers/application_controller.rb

@ -79,17 +79,20 @@ class ApplicationController < LinguaFrancaApplicationController
end end
def do_404 def do_404
params[:_original_action] = params[:action] error_404(status: 404)
params[:action] = 'error-404'
render 'application/404', status: 404
end end
def error_404 def error_404(args = {})
render 'application/404' 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 end
def do_403(template = nil) def do_403(template = nil)
@template = template @template = template
@main_title ||= @page_title
params[:_original_action] = params[:action] params[:_original_action] = params[:action]
params[:action] = 'error-403' params[:action] = 'error-403'
render 'application/permission_denied', status: 403 render 'application/permission_denied', status: 403

6
app/controllers/conferences_controller.rb

@ -529,13 +529,13 @@ class ConferencesController < ApplicationController
@name ||= current_user.username @name ||= current_user.username
@is_host = @this_conference.host? current_user @is_host = @this_conference.host? current_user
steps = registration_steps
return do_404 unless steps.present?
else else
@register_template = :confirm_email @register_template = :confirm_email
end end
steps = registration_steps
return do_404 unless steps.present?
@errors = {} @errors = {}
@warnings = [] @warnings = []
form_step = params[:button] ? params[:button].to_sym : nil form_step = params[:button] ? params[:button].to_sym : nil

21
app/controllers/oauths_controller.rb

@ -4,11 +4,14 @@ class OauthsController < ApplicationController
# sends the user on a trip to the provider, # sends the user on a trip to the provider,
# and after authorizing there back to the callback url. # and after authorizing there back to the callback url.
def oauth def oauth
set_callback
session[:oauth_last_url] = request.referer session[:oauth_last_url] = request.referer
login_at(auth_params[:provider]) login_at(auth_params[:provider])
end end
def callback def callback
set_callback
user_info = (sorcery_fetch_user_hash auth_params[:provider] || {})[:user_info] user_info = (sorcery_fetch_user_hash auth_params[:provider] || {})[:user_info]
user = User.find_by_email(user_info['email']) user = User.find_by_email(user_info['email'])
@ -22,19 +25,6 @@ class OauthsController < ApplicationController
auto_login(user) if user auto_login(user) if user
redirect_to (session[:oauth_last_url] || home_path) 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 end
private private
@ -42,4 +32,9 @@ class OauthsController < ApplicationController
params.permit(:code, :provider) params.permit(:code, :provider)
end end
def set_callback
Sorcery::Controller::Config.send(params[:provider]).callback_url =
"#{request.protocol}#{request.env['HTTP_HOST']}/oauth/callback?provider=facebook"
end
end end

3
app/models/conference.rb

@ -54,7 +54,8 @@ class Conference < ActiveRecord::Base
end end
def registration_status def registration_status
read_attribute(:registration_status).to_sym s = read_attribute(:registration_status)
s.present? ? s.to_sym : nil
end end
def registration_status=(new_registration_status) def registration_status=(new_registration_status)

6
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} = render :partial => 'application/header', :locals => {:image_file => nil}
= row do = row do
= columns(medium: 12) do = columns(medium: 12) do
%h1 = paragraph(_'error.404.description', :p)
=_'error.404.title','This page does not exist!'
=paragraph(_'error.404.description', :p)

2
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}") =@page_title.present? ? I18n.t(@page_title, @page_title_vars) : I18n.t("page_titles.#{page_group.to_s}.#{page_key.to_s}")
= row do = row do
= columns 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}")

9
config/initializers/sorcery.rb

@ -8,13 +8,6 @@ require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if Rails.env.development? 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] Rails.application.config.sorcery.submodules = [:external]
# Here you can configure each submodule's features. # 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.key = "257350517701074"
config.facebook.secret = "2f6ab1fd7eeff9aee73140991fc68314" 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.user_info_mapping = {:email => "email", :username => "username"}
config.facebook.scope = "email" config.facebook.scope = "email"
config.facebook.display = "popup" config.facebook.display = "popup"

7
config/locales/en.yml

@ -5331,6 +5331,8 @@ en:
Add_Workshop: Propose a Workshop Add_Workshop: Propose a Workshop
Workshops_Looking_For_Facilitators: Workshops Looking for Facilitators Workshops_Looking_For_Facilitators: Workshops Looking for Facilitators
All_Workshops: All Workshops All_Workshops: All Workshops
Pre_Registration_Details: Pre-Registration is now open!
Verify_Account: Verify your account
paragraphs: 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. 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 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. 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. 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. 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: questions:
bike: bike:
large: Large large: Large
@ -5563,6 +5568,8 @@ en:
add: "+" add: "+"
previous: Previous previous: Previous
next: Next next: Next
continue: Continue
facebook_sign_in: Facebook Sign In
page_titles: page_titles:
'403': '403':
Please_Confirm_Email: Please confirm your email Please_Confirm_Email: Please confirm your email

Loading…
Cancel
Save