rails_simple_auth 1.0.10 → 1.0.11

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: 5e3b095ff64262301ce80addfe5b6a2bcd05c3356bd36cd3cb0ba545ac78bccb
4
- data.tar.gz: f076015e2bb501c1590eff06f722ae8d18a0dbcb307dd31ab934851abd45c83b
3
+ metadata.gz: 63f51b7959956bc2a4cecb47d58f131fa4e8a54d930d1a3acb29ae9d32602fe9
4
+ data.tar.gz: '0844c3355030f1515b9d14dd5e4fdcbced5972b019bc90deb14f20c3dd6d686f'
5
5
  SHA512:
6
- metadata.gz: de19631e5a5e5f3db9792591442e53bdc29ae7cfc32fb877e2091256d499207d7d363bfa36fa6fbab33172153ca208077ed8bb7d9a0bc97c933877fdd6edfa7f
7
- data.tar.gz: 95e036ece7c8518c326257e018b19b691c1dfe79f0785d562284dae2dc4ba67d28e9f4e962b3d4da0b0ffc5eac672aa8c53f1b8ba6628de9a85b041f65ee52e4
6
+ metadata.gz: d54493c3417312b731eaaf3fda92006be4a63e15b2328468b25094cc701f04d3533dd00d4a41b8f7cf47e85e54293993ceaaee0d28059f8f2521b2477b10df87
7
+ data.tar.gz: 6d236f2ba54009287afe7d52aa0f374b3d9f9a09a4579bc6607606036a7ea05233db8bcaa7b8a690135bb8be27c320ea2218ead5bf2539b83e26c49fb651e3fb
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.11] - 2026-01-19
11
+
12
+ ### Added
13
+
14
+ - **OAuth provider display names** - Configure human-readable names for OAuth buttons
15
+ ```ruby
16
+ # Hash format with custom display names
17
+ config.enable_oauth(google_oauth2: "Google", github: "GitHub")
18
+
19
+ # Symbol format still works (backward compatible)
20
+ config.enable_oauth(:google_oauth2, :github)
21
+ ```
22
+ - `oauth_provider_display_name(provider)` method returns the display name, falling back to titleized provider name with `_oauth2` suffix removed
23
+
10
24
  ## [1.0.10] - 2026-01-19
11
25
 
12
26
  ### Fixed
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RailsSimpleAuth
4
4
  class Configuration
5
- attr_accessor :magic_link_enabled, :email_confirmation_enabled, :oauth_enabled, :oauth_providers, :oauth_link_existing_accounts,
5
+ attr_accessor :magic_link_enabled, :email_confirmation_enabled, :oauth_enabled, :oauth_providers, :oauth_provider_names, :oauth_link_existing_accounts,
6
6
  :magic_link_expiry, :password_reset_expiry, :confirmation_expiry, :session_expiry,
7
7
  :rate_limits,
8
8
  :after_sign_in_path, :after_sign_out_path, :after_sign_up_path, :after_confirmation_path,
@@ -20,6 +20,7 @@ module RailsSimpleAuth
20
20
  @email_confirmation_enabled = true
21
21
  @oauth_enabled = false
22
22
  @oauth_providers = []
23
+ @oauth_provider_names = {}
23
24
  @oauth_link_existing_accounts = true # Allow OAuth to link to existing email accounts
24
25
 
25
26
  @magic_link_expiry = 15.minutes
@@ -87,15 +88,36 @@ module RailsSimpleAuth
87
88
  "Original error: #{e.message}"
88
89
  end
89
90
 
91
+ # Enable OAuth providers with optional display names
92
+ # Usage:
93
+ # enable_oauth(:google_oauth2, :github) # Uses default display names
94
+ # enable_oauth(google_oauth2: "Google", github: "GitHub") # Custom display names
90
95
  def enable_oauth(*providers)
91
96
  self.oauth_enabled = true
92
- self.oauth_providers = providers.map(&:to_sym)
97
+
98
+ if providers.length == 1 && providers.first.is_a?(Hash)
99
+ # Hash format: { google_oauth2: "Google", github: "GitHub" }
100
+ provider_hash = providers.first
101
+ self.oauth_providers = provider_hash.keys.map(&:to_sym)
102
+ self.oauth_provider_names = provider_hash.transform_keys(&:to_sym)
103
+ else
104
+ # Symbol format: :google_oauth2, :github (backward compatible)
105
+ self.oauth_providers = providers.map(&:to_sym)
106
+ self.oauth_provider_names = {}
107
+ end
93
108
  end
94
109
 
95
110
  def oauth_provider_enabled?(provider)
96
111
  oauth_enabled && oauth_providers.include?(provider.to_sym)
97
112
  end
98
113
 
114
+ # Get display name for an OAuth provider
115
+ # Falls back to titleized provider name if no custom name is configured
116
+ def oauth_provider_display_name(provider)
117
+ provider_sym = provider.to_sym
118
+ oauth_provider_names[provider_sym] || provider.to_s.gsub(/_oauth2$/, "").titleize
119
+ end
120
+
99
121
  def rate_limit_for(action)
100
122
  rate_limits&.dig(action.to_sym)
101
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSimpleAuth
4
- VERSION = '1.0.10'
4
+ VERSION = '1.0.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_simple_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuznetsov