rails_simple_auth 1.2.0 → 1.2.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/CHANGELOG.md +8 -0
- data/README.md +6 -0
- data/lib/rails_simple_auth/models/concerns/oauth_connectable.rb +31 -9
- data/lib/rails_simple_auth/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: 92f4718f32ac9f010bc24be665915952c9dcf5d02340c07e7692b2a053a282ce
|
|
4
|
+
data.tar.gz: 71ba9817ebe4fcefd815aa47e0f99d02261349d78a0532b0a6f3fca22442d6ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97e9c562f6993c03661ef81eee4e534ad25496b3f36f3f46d1b559a860835a8dde49f190eeed0368a5abc7d0d06e11d2a596873d75af7484983f3afe043397d5
|
|
7
|
+
data.tar.gz: cf069335a5b94f84b163057116730d1feb4d428d43b9c3ccb5da056f73b92a13ef2dbeda7cf8c939c858480243bcf93e47ec7899f63c12864398d21d4fcd43c3
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.1] - 2026-09-15
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- OAuth linking reloads the account under a row lock so concurrent confirmation or pending email changes are preserved; if the matched email changes before linking, sign-in is rejected.
|
|
15
|
+
- Confirm existing accounts when linking by email through a trusted OAuth provider, before calling the host application's `assign_oauth_attributes` hook. Preserve existing confirmation timestamps and pending email changes. Accounts found by provider and UID remain unchanged.
|
|
16
|
+
- Return `nil` when saving an existing OAuth account link fails, preventing authentication with unsaved changes.
|
|
17
|
+
|
|
10
18
|
## [1.2.0] - 2026-05-23
|
|
11
19
|
|
|
12
20
|
### Changed
|
data/README.md
CHANGED
|
@@ -217,6 +217,12 @@ class User < ApplicationRecord
|
|
|
217
217
|
end
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
+
Email-based account linking is enabled by default (`config.oauth_link_existing_accounts = true`). Only enable it for providers you trust to supply verified email addresses; the gem does not inspect provider-specific verification claims. Set it to `false` to reject linking by email.
|
|
221
|
+
|
|
222
|
+
New OAuth accounts and existing accounts linked by email are automatically confirmed when they have a `confirmed_at` column. Existing confirmation timestamps and pending email changes are preserved. Confirmation is assigned before `assign_oauth_attributes`, so your hook can use it to update application-specific state. The hook and confirmation changes are saved together; a failed save returns `nil`.
|
|
223
|
+
|
|
224
|
+
Accounts found by provider and UID return unchanged, including their email and confirmation state. Applications with historical unconfirmed OAuth accounts should handle their backfill separately.
|
|
225
|
+
|
|
220
226
|
## Temporary Users (Guest Accounts)
|
|
221
227
|
|
|
222
228
|
Temporary users allow visitors to try your app without creating an account. They get a real user record with full functionality, then can convert to a permanent account later by providing email and password.
|
|
@@ -41,16 +41,38 @@ module RailsSimpleAuth
|
|
|
41
41
|
existing_user = find_by_email(email)
|
|
42
42
|
if existing_user
|
|
43
43
|
# Configurable: allow linking OAuth to existing accounts
|
|
44
|
-
#
|
|
44
|
+
# Only enable for providers trusted to supply verified email addresses.
|
|
45
45
|
if RailsSimpleAuth.configuration.oauth_link_existing_accounts
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
matched_email = existing_user.email
|
|
47
|
+
return existing_user.with_lock do
|
|
48
|
+
# Reload under the lock before checking confirmation state.
|
|
49
|
+
next nil if existing_user.email != matched_email
|
|
50
|
+
|
|
51
|
+
# Confirm the current email only; OAuth does not verify a pending replacement.
|
|
52
|
+
pending_email = existing_user.respond_to?(:unconfirmed_email) &&
|
|
53
|
+
existing_user.unconfirmed_email.present?
|
|
54
|
+
if existing_user.respond_to?(:confirmed_at=) && existing_user.confirmed_at.nil? && !pending_email
|
|
55
|
+
existing_user.confirmed_at = Time.current
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Call hook to store OAuth credentials on existing user
|
|
59
|
+
if existing_user.respond_to?(:assign_oauth_attributes)
|
|
60
|
+
existing_user.assign_oauth_attributes(auth_hash)
|
|
61
|
+
end
|
|
62
|
+
if existing_user.changed? && !existing_user.save
|
|
63
|
+
Rails.logger.error(
|
|
64
|
+
"[RailsSimpleAuth] OAuth account linking failed for email: #{email}, " \
|
|
65
|
+
"provider: #{provider}, errors: #{existing_user.errors.full_messages.join(', ')}"
|
|
66
|
+
)
|
|
67
|
+
next nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
Rails.logger.info(
|
|
71
|
+
"[RailsSimpleAuth] OAuth linked to existing account: #{email}. " \
|
|
72
|
+
"Provider: #{provider}."
|
|
73
|
+
)
|
|
74
|
+
existing_user
|
|
75
|
+
end
|
|
54
76
|
else
|
|
55
77
|
Rails.logger.warn(
|
|
56
78
|
"[RailsSimpleAuth] OAuth login rejected for existing email: #{email}. " \
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_simple_auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Kuznetsov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bcrypt
|