livechat 0.3.3 → 0.3.4

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: 3263710888d695851123f5afeffc0dd73985901e0ad559f5d04562a59c411537
4
- data.tar.gz: 9db6f6b5df671b05b594dd174180cc54c2988695aac907ab3f7f3e38c32df732
3
+ metadata.gz: aa83a99e1d1ebe0259347b286862ec7cf7cfffbfe47ea4a624baff36b3ca066e
4
+ data.tar.gz: 0d017808858c6dfbce423e283b061476a74b3075b42bb70c3f10c54fb74b5622
5
5
  SHA512:
6
- metadata.gz: c5ae2806f1b7f1c8d08b14bc61043c8fe23159873c260a75c3ed6a5b263bc2ada95630af19a323a64c3de774d107e17aef8094454535460bba76cb10c91d5846
7
- data.tar.gz: cda4c08755760e0a1a1996be4aa5165e8d7ddf10ca86cd0362905b0d02c5ee1dd8e73f3a2f8dcec3cbb9b3b68a23418d3898f9bca48146365799544ca029d332
6
+ metadata.gz: 97dc8a43bfb5ab7fecd0dabdfaf5f126e3346b97e73f56aa96129331046e74355bbc201a7fc0ab010c1ef0e48a73d15ec7aaadac0dd185c4310480271486984c
7
+ data.tar.gz: e1469a54e206b39b539d6dacc767568caad7a44da3540d5ff3b746fb0affb74e83224f3ca9f0ea87163f2796656d66b274aaa58332e1cd40ddfda9b441b1028d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4
4
+
5
+ - Docs: show how to wire `current_user` with Rails 8's built-in authentication
6
+ (`bin/rails generate authentication`), alongside the existing Devise/Warden
7
+ example — in the README and the generated initializer.
8
+
3
9
  ## 0.3.3
4
10
 
5
11
  - Accessibility: on phones (where the panel is a full-screen modal) focus is
data/README.md CHANGED
@@ -91,6 +91,20 @@ Livechat.configure do |config|
91
91
  end
92
92
  ```
93
93
 
94
+ `current_user` (and any admin gate) receives the raw request, so it works
95
+ with whatever auth you have:
96
+
97
+ ```ruby
98
+ # Devise / Warden:
99
+ config.current_user = ->(request) { request.env["warden"]&.user }
100
+
101
+ # Rails 8 built-in auth (bin/rails generate authentication):
102
+ config.current_user = lambda do |request|
103
+ token = request.cookies["session_token"]
104
+ Session.find_signed(token)&.user if token
105
+ end
106
+ ```
107
+
94
108
  ### Brand color
95
109
 
96
110
  ```ruby
@@ -16,7 +16,15 @@ Livechat.configure do |config|
16
16
  # Resolve the current user (optional). Return an object responding to #id,
17
17
  # or nil. Signed-in visitors keep one conversation across devices; guests
18
18
  # are tracked with a cookie. The same user is the agent when replying.
19
+ #
20
+ # Devise / Warden:
19
21
  # config.current_user = ->(request) { request.env["warden"]&.user }
22
+ #
23
+ # Rails 8 built-in auth (bin/rails generate authentication):
24
+ # config.current_user = lambda do |request|
25
+ # token = request.cookies["session_token"]
26
+ # Session.find_signed(token)&.user if token
27
+ # end
20
28
 
21
29
  # How visitors appear in the inbox.
22
30
  # config.visitor_label = ->(user) { user.name.presence || user.email }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Livechat
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov