Class: Leash::Client::AuthFacade
- Inherits:
-
Object
- Object
- Leash::Client::AuthFacade
- Defined in:
- lib/leash/client.rb
Overview
‘leash.auth` — sync, non-throwing wrapper around Auth.get_user.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
-
#initialize(request) ⇒ AuthFacade
constructor
A new instance of AuthFacade.
-
#user ⇒ Leash::User?
Note: this method reads ONLY the ‘leash-auth` cookie from the request.
Constructor Details
#initialize(request) ⇒ AuthFacade
Returns a new instance of AuthFacade.
104 105 106 |
# File 'lib/leash/client.rb', line 104 def initialize(request) @request = request end |
Instance Method Details
#authenticated? ⇒ Boolean
126 127 128 |
# File 'lib/leash/client.rb', line 126 def authenticated? !user.nil? end |
#user ⇒ Leash::User?
Note: this method reads ONLY the ‘leash-auth` cookie from the request. `Authorization: Bearer <jwt>` headers are deliberately NOT used for identity resolution here — they’re reserved for env-fetch fallback + CLI/agent flows. To get the user from a Bearer token, you’d hit ‘/api/auth/me` directly with that token.
117 118 119 120 121 122 123 |
# File 'lib/leash/client.rb', line 117 def user Leash::Auth.get_user(@request) rescue Leash::AuthError nil rescue StandardError nil end |