Rails 3 - Help! Subdomains - Users Cannot Logout? - ruby-on-rails-3

I've followed the ascii cast up at http://asciicasts.com/episodes/221-subdomains-in-rails-3
I've set the :domain option to :all in session store:
Rails.application.config.session_store :cookie_store, :key => '_bloggit_session', :domain => :all
Now my users cannot logout.
Any ideas why? I've tried deleting all cookies and then trying again, etc.
I can login, and my session is carried across subdomains, but I can't logout.
I am using rails 3, and authlogic for authentication.
Thanks for any help!

Specify the Domain.
I had the exact same issue and the culprit was using :domain => :all.
You'd think that would be all you need but it seems to cause some problems so I had to manually specify the domain with a preceding dot (.), like so:
:domain => '.lvh.me'
This fixed the issue in development. You can use different ways to set this in your various environments but I landed on something like this:
Rails.application.config.session_store :cookie_store,
:key => '_bloggit_session',
:domain => { production: '.bloggit.com',
staging: '.bloggitstaging.com',
development: '.lvh.me' }.fetch(Rails.env.to_sym)

Related

Devise with omniauth facebook for multiple subdomains?

I will have several subdomains on my site, one per language, and authentication is via facebook-omniauth. What is the best way to establish the constants (FB id, secret) for all the subdomains? I'm using Rails 3.1.x
The solution:
/config/initializers/session_store.rb
InfiniteshelterComDevise::Application.config.session_store :cookie_store,
:key => '_infiniteshelter.com-devise_session',
:domain => TOP_DOMAIN
and the constant TOP_DOMAIN is something like '.infiniteshelter.com' for infiniteshelter.com, pt.infiniteshelter.com and ru.infiniteshelter.com.

Suburl's ruby on rails

I'm having a problem using a sub url, when I try to access through authentication page, it generates an authentication cookie, but i keep on login screen and if i try access some page it says that i must got logged.
If you mean sub-domain, you have to change, your config/initializer/session_store.rb
And add your subdomain, with a dot before like that :
Rails.application.config.session_store :cookie_store, :key => '_key', :domain => ".yourdomain.com"

Followed The Google OmniAuth tutorial but getting rejected from Server, how to read the rejection notice

This is the tutorial I followed. Scroll down to the Google open-id integration:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
On the server I get the following rejection message after clicking the login with google link:
WARNING: making https request to https://www.google.com/accounts/o8/id without verifying server certificate; no CA path was specified.
processing by users omniauthcallbackscontroller failure as html
EDIT the following two lines fixed the CA path Warning but did nothing to fix the failure as html problem or move me forward
require "openid/fetchers"
OpenID.fetcher.ca_file = "/etc/ssl/certs/ca-certificates.crt"
It then re-routes me to users/sign_in.
My devise config line looks like this:
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'), :name => 'google', :identifier => 'https://www.google.com/acounts/o8/id', :require => 'omniauth-openid'
My research tells me that I'm probably hitting the openID servers but that I'm getting rejected. Is there anyway to get more info from some sort of rejection notice? What could be wrong with my request?
One thing I thought of was credentials for open ID but I didn't see anywhere in the tutorial where I was supposed to get or enter any credentials.
Try to specify the ca_path:
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'),
:name => 'google',
:identifier => 'https://www.google.com/acounts/o8/id',
:require => 'omniauth-openid',
:client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
And see if it works.

Devise (or OmniAuth) appending "#_" to URL after sign in

I'm using Devise and OmniAuth (Facebook) in a Rails 3 app. I just started noticing this behavior recently.
When a user signs in, he is redirected to his dashboard, however, the characters "#_" are being appended to the url. The only thing I can think of now is a conflict between the routes created by:
resources :users
and
# User Authentication
devise_for :users,
:singular => :user,
:controllers => {:registrations => 'registrations'} do
get 'logout' => 'devise/sessions#destroy'
end
Is this only happening with Facebook? If so it is probably related to: https://developers.facebook.com/blog/post/552/. Notice how Facebook outlines that they changed the session redirect handling to append a #_=_ to responses. I'm not sure why this was done, however you may be able to fix it by supplying an explicit redirect url.

Setting Up Devise & Sendgrid on Heroku

My site is hosted on Heroku and I installed the Sendgrid Add-On as it looked almost too good to be true - but so far none of the email functionality is working. I have read the documentation and it clearly says just add-the add on - is more configuration required to get Devise working?
When I select 'send me new password' I get a 404 page which makes me think there is more to this. Like how does Sendgrid know/where to use the pre-installed Devise templates?
Thx.
I just set up Devise and SendGrid this morning and have no problems. I'm going to resume the steps I took.
First, install Devise and SendGrid. Congratulations, you've already done that ;)
Then, for production, add this to your files:
config/initializers/devise.rb :
config.mailer_sender = "mail-to-send#from.com"
Set up Rails ActionMailer to use SendGrid
config/environments/production.rb
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:address => "smtp.sendgrid.net",
:port => 587,
:enable_starttls_auto => true,
:authentication => :plain,
:domain => "yourdomain.com"
}
And everything's working great with that. Sign up confirmations, password recovery...
Also, you should use Logging Expanded (it's Free!) and check your logs with heroku logs --tail (for real time).
If you still get errors, post your logs.
Have a good day !
I've used the sendgrid Add-On and it really should just work. Like you said, even the docs say so:
Rails apps using ActionMailer will just work, no setup is needed after the add-on is installed.
So, this makes me think something else is going on. Have you tried using the heroku logs command to see if your application is logging any errors?