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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96047a475a532a0f692f9ee1fbbde4989e6d563ae91706c054defd7cfdd21a32
4
- data.tar.gz: fc81798aa5b2a5b8ff45f2b187ae5f3e63e41e79917260fbb28c993095b65b08
3
+ metadata.gz: 2b835fdf877c7f3170cbd2ffd0e04e7307122e2c1da9dbb84d8a959b42fb0e45
4
+ data.tar.gz: 7658a46b51fb03b637c7563d8579956af53c7d511897b21ade25b7f27b989a11
5
5
  SHA512:
6
- metadata.gz: 39ff9a79b7f682c4c7351016c490ed98b691f7b81f8a137baa84e9038e0d4b25f4b6be056896da1a126024edf3a0629c2138d8c63ee5bc622f7514759004f0b1
7
- data.tar.gz: a88fa475189412f5d24ec13b6aa3a618d12340889cacbcb8406bc1399ea4e84bf7475c66bed59262b5e6799e09961c0e909a71a5aa7d8d02be919c49bdbb8912
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
@@ -1,5 +1,5 @@
1
1
  module Calib
2
2
  module Rails
3
- VERSION = '0.1.7'
3
+ VERSION = '0.1.8'
4
4
  end
5
5
  end
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.7
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-07 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails