devise-guests 0.8.0 → 0.8.1
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/.github/workflows/tests.yml +30 -1
- data/CHANGELOG.md +25 -0
- data/README.md +23 -5
- data/lib/devise-guests/controllers/helpers.rb +4 -0
- data/lib/devise-guests/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7944106e6394d186fa877f614689e47b1059488d6e3d5400ed2eb2204e324f3b
|
4
|
+
data.tar.gz: 817faf49e6a0ad620f2fe35014f1adf1783f3f5177cc7579e4f9bc4cb2872ecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98e77fdda01fa6982fb3f2851eb84870ab0a9aeaae60e0bba91c98f55454a705056953738559caad400a162aa7d6d55b3e0b510427f573e094c16eb05d85b181
|
7
|
+
data.tar.gz: 4e9d799034284f840332366ae2d79f87c72a1eeaf1f4526287cd76fd8f50126a51d74749977b0c31479e0c6ab8ff377b9ef2a4e932ec2feb9ada9f6901074e7b
|
data/.github/workflows/tests.yml
CHANGED
@@ -12,10 +12,39 @@ on:
|
|
12
12
|
branches: [ master ]
|
13
13
|
pull_request:
|
14
14
|
branches: [ master ]
|
15
|
+
types:
|
16
|
+
- opened
|
17
|
+
- synchronize
|
18
|
+
- reopened
|
19
|
+
- ready_for_review
|
20
|
+
- labeled
|
21
|
+
- unlabeled
|
15
22
|
|
16
23
|
jobs:
|
24
|
+
changelog:
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@v2
|
28
|
+
- id: read-version
|
29
|
+
run: |
|
30
|
+
echo "::set-output name=VERSION::`cat lib/devise-guests/version.rb | grep -i version | awk '{ print $3 }' | sed -e 's/\"//g'`"
|
31
|
+
- uses: dangoslen/changelog-enforcer@v2.3.1
|
32
|
+
with:
|
33
|
+
skipLabels: 'skip-changelog'
|
34
|
+
expectedLatestVersion: ${{ steps.read-version.outputs.VERSION }}
|
35
|
+
lint:
|
36
|
+
runs-on: ubuntu-latest
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: '2.6'
|
42
|
+
bundler-cache: true
|
43
|
+
- run: bundle exec standardrb
|
17
44
|
test:
|
18
|
-
|
45
|
+
needs:
|
46
|
+
- changelog
|
47
|
+
- lint
|
19
48
|
runs-on: ubuntu-latest
|
20
49
|
strategy:
|
21
50
|
matrix:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.8.1] - 2021-10-26
|
8
|
+
### Changed
|
9
|
+
- Simplify guest transfer ([#38](https://github.com/cbeer/devise-guests/pull/38))
|
10
|
+
|
11
|
+
## [0.8.0] - 2021-10-25
|
12
|
+
### Added
|
13
|
+
- Allow setting of custom params on guest model ([#31](https://github.com/cbeer/devise-guests/pull/31)) by [@pacso](https://github.com/pacso)
|
14
|
+
- Allow deletion of guest records to optionally be skipped ([#32](https://github.com/cbeer/devise-guests/pull/32)) by [@pacso](https://github.com/pacso)
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Switch to SecureRandom.uuid for guest_user_unique_suffix ([#28](https://github.com/cbeer/devise-guests/pull/28)) by [@notch8](https://github.com/notch8)
|
18
|
+
- Update combustion gem ([#29](https://github.com/cbeer/devise-guests/pull/29)) by [@notch8](https://github.com/notch8)
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- Defining the logging_in callback when the controller loads ([#34](https://github.com/cbeer/devise-guests/pull/34)) by [@davidkuz](https://github.com/davidkuz)
|
22
|
+
|
23
|
+
[Unreleased]: https://github.com/cbeer/devise-guests/compare/v0.8.1...HEAD
|
24
|
+
[0.8.1]: https://github.com/cbeer/devise-guests/compare/v0.8.0...v0.8.1
|
25
|
+
[0.8.0]: https://github.com/cbeer/devise-guests/compare/v0.7.0...v0.8.0
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Devise Guests
|
2
|
+
[](https://badge.fury.io/rb/devise-guests)
|
2
3
|
[](https://github.com/cbeer/devise-guests/actions/workflows/tests.yml)
|
3
4
|
[](https://github.com/testdouble/standard)
|
4
5
|
|
@@ -41,14 +42,11 @@ guest_user # ( for anonymous users)
|
|
41
42
|
### Transferring Guest to User on Login
|
42
43
|
|
43
44
|
During the login process you may want to transfer things from your guest user to the account the logged into.
|
44
|
-
To do so,
|
45
|
+
To do so, add the following method to your ApplicationController:
|
45
46
|
|
46
47
|
```ruby
|
47
|
-
define_callbacks :logging_in_user
|
48
|
-
set_callback :logging_in_user, :before, :transfer_guest_to_current_user
|
49
|
-
|
50
48
|
private
|
51
|
-
def
|
49
|
+
def transfer_guest_to_user
|
52
50
|
# At this point you have access to:
|
53
51
|
# * current_user - the user they've just logged in as
|
54
52
|
# * guest_user - the guest user they were previously identified by
|
@@ -75,6 +73,26 @@ def guest_user_params
|
|
75
73
|
end
|
76
74
|
```
|
77
75
|
|
76
|
+
### Non-standard authentication keys
|
77
|
+
|
78
|
+
By default Devise will use `:email` as the authentication key for your model. If for some reason you have modified your
|
79
|
+
Devise config to use an alternative attribute (such as `:phone_number`) you will need to provide a method to generate
|
80
|
+
the value of this attribute for any guest users which are created.
|
81
|
+
|
82
|
+
Sticking with the `:phone_number` example, you should define the following method in your `application_controller.rb`:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
private
|
86
|
+
def guest_phone_number_authentication_key(key)
|
87
|
+
key &&= nil unless key.to_s.match(/^guest/)
|
88
|
+
key ||= "guest_447" + 9.times.map { SecureRandom.rand(0..9) }.join
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
Validations are skipped when creating guest users, but if you need to rely on future modifications to the guest record
|
93
|
+
passing validations, then you should ensure that this default value for guests is generated in such a way as to be
|
94
|
+
valid.
|
95
|
+
|
78
96
|
### Prevent deletion of guest records
|
79
97
|
|
80
98
|
By default, when signing in from a guest account to an authenticated account, the guest user is destroyed. You have an
|
@@ -74,6 +74,9 @@ module DeviseGuests::Controllers
|
|
74
74
|
false
|
75
75
|
end
|
76
76
|
|
77
|
+
def transfer_guest_to_#{mapping}
|
78
|
+
end
|
79
|
+
|
77
80
|
METHODS
|
78
81
|
|
79
82
|
ActiveSupport.on_load(:action_controller) do
|
@@ -81,6 +84,7 @@ module DeviseGuests::Controllers
|
|
81
84
|
helper_method "guest_#{mapping}", "current_or_guest_#{mapping}"
|
82
85
|
end
|
83
86
|
define_callbacks "logging_in_#{mapping}"
|
87
|
+
set_callback :"logging_in_#{mapping}", :"transfer_guest_to_#{mapping}"
|
84
88
|
end
|
85
89
|
end
|
86
90
|
end
|
@@ -35,6 +35,7 @@ describe ApplicationController, type: :controller do
|
|
35
35
|
allow(@controller).to receive(:session) { {guest_user_id: 123} }
|
36
36
|
|
37
37
|
expect(@controller).to receive(:run_callbacks).with(:logging_in_user).and_call_original
|
38
|
+
expect(@controller).to receive(:transfer_guest_to_user).and_call_original
|
38
39
|
|
39
40
|
@controller.current_or_guest_user
|
40
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-guests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".github/workflows/tests.yml"
|
134
134
|
- ".gitignore"
|
135
135
|
- ".standard.yml"
|
136
|
+
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- LICENSE
|
138
139
|
- README.md
|