Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rendezvous
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
rendezvous
Commits
710bbd46
Commit
710bbd46
authored
Feb 27, 2014
by
tady
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from tadyjp/wip/140227_login_redirect
ログイン時にアクセスURLへリダイレクト #18
parents
1f8218d0
8c44e50b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletions
+17
-1
app/controllers/application_controller.rb
+5
-0
app/controllers/users/omniauth_callbacks_controller.rb
+1
-1
spec/controllers/application_controller_spec.rb
+11
-0
No files found.
app/controllers/application_controller.rb
View file @
710bbd46
...
@@ -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
...
...
app/controllers/users/omniauth_callbacks_controller.rb
View file @
710bbd46
...
@@ -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
...
...
spec/controllers/application_controller_spec.rb
0 → 100644
View file @
710bbd46
require
'spec_helper'
describe
ApplicationController
do
pending
'#require_login'
pending
'#after_sign_in_path_for'
pending
'#rescue_from'
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment