calib-rails 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/calib/devise/friendly_forwardable.rb +15 -2
- data/lib/calib/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b835fdf877c7f3170cbd2ffd0e04e7307122e2c1da9dbb84d8a959b42fb0e45
|
4
|
+
data.tar.gz: 7658a46b51fb03b637c7563d8579956af53c7d511897b21ade25b7f27b989a11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c85811ffbb49bb116d008c560947dcc54173849183996bb389ce0109358dcd89cd4448d946175ee0c6b7d52bd5f779e3fd3479b4d33a96fc741e328ac9a10a0
|
7
|
+
data.tar.gz: 2625dd135e9963f844cf2bf0dfe702732f16e8f5f4ef6f503451712207cb267c699acd2cf2b8631f941dfadd06eb314fac38bbef2e5adf81a2b6aece504f33dd
|
@@ -1,23 +1,34 @@
|
|
1
|
+
# == A Module for Friendly forwarding
|
2
|
+
# Redirect back to current page after sign in.
|
3
|
+
# @see https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update
|
4
|
+
#
|
5
|
+
# [usage]
|
6
|
+
# class ApplicationController < ActionController::Base
|
7
|
+
# include Calib::Devise::FriendlyForwardable
|
8
|
+
# ...
|
9
|
+
# end
|
1
10
|
module Calib::Devise::FriendlyForwardable
|
2
11
|
extend ActiveSupport::Concern
|
3
12
|
|
4
13
|
included do
|
5
|
-
# @see https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update
|
6
14
|
before_action :store_location!, if: :storable_location?
|
7
15
|
end
|
8
16
|
|
9
17
|
private
|
10
18
|
|
19
|
+
# overwrite _after_sign_in_path_for_ provided Devise
|
11
20
|
def after_sign_in_path_for(resource)
|
12
21
|
friendly_forwarding_path(resource)
|
13
22
|
end
|
14
23
|
|
15
|
-
# path with stored_location or root
|
24
|
+
# path with stored_location or root for redirect
|
25
|
+
#
|
16
26
|
# @see https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
|
17
27
|
def friendly_forwarding_path(r = devise_key_for_store_location)
|
18
28
|
request.env['omniauth.origin'] || stored_location_for(r) || signed_in_root_path(r)
|
19
29
|
end
|
20
30
|
|
31
|
+
# if this is true, store location.
|
21
32
|
def storable_location?
|
22
33
|
request.get? &&
|
23
34
|
is_navigational_format? &&
|
@@ -26,11 +37,13 @@ module Calib::Devise::FriendlyForwardable
|
|
26
37
|
!request.xhr?
|
27
38
|
end
|
28
39
|
|
40
|
+
# sotore current page's location
|
29
41
|
def store_location!
|
30
42
|
Rails.logger.debug("store_#{devise_key_for_store_location}_location!: #{request.fullpath}")
|
31
43
|
store_location_for(devise_key_for_store_location, request.fullpath)
|
32
44
|
end
|
33
45
|
|
46
|
+
# primary devise key for storing location
|
34
47
|
def devise_key_for_store_location
|
35
48
|
Devise.mappings.keys[0]
|
36
49
|
end
|
data/lib/calib/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calib-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ms2sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|