-
-
Save BlackFoks/6432155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :ensure_proper_protocol | |
protected | |
def ssl_allowed_action? | |
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) || | |
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) || | |
(params[:controller] == 'users/omniauth_callbacks') | |
end | |
def ensure_proper_protocol | |
if request.ssl? && !ssl_allowed_action? | |
redirect_to "http://" + request.host + request.fullpath | |
end | |
end | |
def after_sign_in_path_for(resource_or_scope) | |
root_url(:protocol => 'http') | |
end | |
def after_sign_out_path_for(resource_or_scope) | |
root_url(:protocol => 'http') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::RegistrationsController < Devise::RegistrationsController | |
force_ssl :only => [:new, :create, :edit, :update] | |
protected | |
def after_inactive_sign_up_path_for(resource) | |
root_url(:protocol => 'http') | |
end | |
def after_sign_up_path_for(resource) | |
root_url(:protocol => 'http') | |
end | |
def after_update_path_for(resource) | |
edit_user_registration_url(:protocol => 'http') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::SessionsController < Devise::SessionsController | |
force_ssl :only => [:new, :create] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment