Commit 8c44e50b by tady

ログイン時にアクセスURLへリダイレクト #18

parent 1f8218d0
......@@ -6,10 +6,15 @@ class ApplicationController < ActionController::Base
def require_login
unless user_signed_in?
flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url
redirect_to root_path
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|
render text: "Required parameter missing: #{parameter_missing_exception.param}", status: :bad_request
end
......
......@@ -3,7 +3,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
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$/
redirect_to root_path, flash: { alert: 'Your email address is not permitted.' }
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