Commit 710bbd46 by tady

Merge pull request #19 from tadyjp/wip/140227_login_redirect

ログイン時にアクセスURLへリダイレクト #18
parents 1f8218d0 8c44e50b
...@@ -6,10 +6,15 @@ class ApplicationController < ActionController::Base ...@@ -6,10 +6,15 @@ class ApplicationController < ActionController::Base
def require_login def require_login
unless user_signed_in? unless user_signed_in?
flash[:alert] = 'You need Login!' flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url
redirect_to root_path redirect_to root_path
end end
end end
def after_sign_in_path_for(resource)
session[:login_redirect_to] || request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception| rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception|
render text: "Required parameter missing: #{parameter_missing_exception.param}", status: :bad_request render text: "Required parameter missing: #{parameter_missing_exception.param}", status: :bad_request
end end
......
...@@ -3,7 +3,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -3,7 +3,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
email = request.env['omniauth.auth'].info['email'] email = request.env['omniauth.auth'].info['email']
# reject if email is not zigexn nor ventura # reject if email is not zigexn nor ventura.
if email !~ /@zigexn\.co\.jp$/ && email !~ /@zigexn\.vn$/ if email !~ /@zigexn\.co\.jp$/ && email !~ /@zigexn\.vn$/
redirect_to root_path, flash: { alert: 'Your email address is not permitted.' } redirect_to root_path, flash: { alert: 'Your email address is not permitted.' }
return return
......
require 'spec_helper'
describe ApplicationController do
pending '#require_login'
pending '#after_sign_in_path_for'
pending '#rescue_from'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment