quo_vadis 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -0
- data/lib/quo_vadis/constraints/logged_in.rb +13 -0
- data/lib/quo_vadis/constraints/logged_out.rb +13 -0
- data/lib/quo_vadis/version.rb +1 -1
- data/lib/quo_vadis.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d059bd573146f59fff8f4fff1ef953c4da0bff83b07125efafadfd40334a9a8
|
4
|
+
data.tar.gz: 744bd5ac56082016453309608721c76e37dcb8827f1c7111102d8a0d06961608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 746819329e2b544e00ca92ccf75cd5293f58160da3243db0c0d6b9dba6d70fde94e59492fd2d73387e20d5f60487dbb98f56eb8c618573215a6b9efd027b4442
|
7
|
+
data.tar.gz: caf55aa31161fe96980ab58b2a3d477202e03b80fa2a4a684477bfb6f3aef4c4033ff670b03f2d434cbda45ff4bc23291d288b196440f372545c1eaccd89732f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -137,6 +137,23 @@ Call this to find out whether a user has authenticated with a password.
|
|
137
137
|
Available in controllers and views.
|
138
138
|
|
139
139
|
|
140
|
+
### Routes
|
141
|
+
|
142
|
+
You can use routing constraints to restrict routes to logged-in or logged-out users. For example:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
Rails.application.routes.draw do
|
146
|
+
constraints(QuoVadis::Constraints::LoggedOut) do
|
147
|
+
root "pages#index"
|
148
|
+
end
|
149
|
+
|
150
|
+
constraints(QuoVadis::Constraints::LoggedIn) do
|
151
|
+
root "dashboard#show", as: :dashboard
|
152
|
+
end
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
|
140
157
|
### Views
|
141
158
|
|
142
159
|
You can use `authenticated_model` and `logged_in?` in your views. For example:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module QuoVadis
|
2
|
+
module Constraints
|
3
|
+
|
4
|
+
class LoggedIn
|
5
|
+
def self.matches?(request)
|
6
|
+
cookies = ActionDispatch::Cookies::CookieJar.build(request, request.cookies)
|
7
|
+
session_id = cookies.encrypted[QuoVadis.cookie_name]
|
8
|
+
session_id && QuoVadis::Session.find_by(id: session_id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module QuoVadis
|
2
|
+
module Constraints
|
3
|
+
|
4
|
+
class LoggedOut
|
5
|
+
def self.matches?(request)
|
6
|
+
cookies = ActionDispatch::Cookies::CookieJar.build(request, request.cookies)
|
7
|
+
session_id = cookies.encrypted[QuoVadis.cookie_name]
|
8
|
+
session_id.nil? || QuoVadis::Session.find_by(id: session_id).nil?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/lib/quo_vadis/version.rb
CHANGED
data/lib/quo_vadis.rb
CHANGED
@@ -117,6 +117,8 @@ require_relative 'quo_vadis/ip_masking'
|
|
117
117
|
require_relative 'quo_vadis/model'
|
118
118
|
require_relative 'quo_vadis/current_request_details'
|
119
119
|
require_relative 'quo_vadis/controller'
|
120
|
+
require_relative 'quo_vadis/constraints/logged_in'
|
121
|
+
require_relative 'quo_vadis/constraints/logged_out'
|
120
122
|
|
121
123
|
ActiveSupport.on_load(:action_controller) do
|
122
124
|
include QuoVadis::Controller
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quo_vadis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- db/migrate/202102150904_setup.rb
|
126
126
|
- lib/generators/quo_vadis/install_generator.rb
|
127
127
|
- lib/quo_vadis.rb
|
128
|
+
- lib/quo_vadis/constraints/logged_in.rb
|
129
|
+
- lib/quo_vadis/constraints/logged_out.rb
|
128
130
|
- lib/quo_vadis/controller.rb
|
129
131
|
- lib/quo_vadis/crypt.rb
|
130
132
|
- lib/quo_vadis/current_request_details.rb
|
@@ -219,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
221
|
- !ruby/object:Gem::Version
|
220
222
|
version: '0'
|
221
223
|
requirements: []
|
222
|
-
rubygems_version: 3.5.
|
224
|
+
rubygems_version: 3.5.11
|
223
225
|
signing_key:
|
224
226
|
specification_version: 4
|
225
227
|
summary: Multifactor authentication for Rails 6 and 7.
|