rodauth-select-account 0.0.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96167bb6a6cb514dfdb4b0eb19cd1a231f9938326a2f199ebdc458202d2c91c4
4
- data.tar.gz: a8b6e0090b49d59161c66537bda1cf4dac1cbda19692a20c3254535c1257bf4a
3
+ metadata.gz: 0b3ae1b644a42cc9fd9b6cd06937820f93dba507756668480ba0c3cb3b77d072
4
+ data.tar.gz: c96c9d556acaa1d4f6af1dea63544773edcf8ca2e4538fbab7ce867c64be59c8
5
5
  SHA512:
6
- metadata.gz: 63602f5524af960c0ccfab9a8632d34c1a2678d046dd538381cdbe6d0feb03e16a340ab1f4d8dc3d31a85e2934bd850a7830d58ba04aad9af4223648d194af06
7
- data.tar.gz: 8809b6233fb99fda935134f0115488f7cc89a443f00e8fc8dd3eea3465f1f970a451b30fea6ef277ed961618767854603fa6e41ee9bdbd69691e1374146e4d62
6
+ metadata.gz: 5166fbda42b1e662b34664c7860efc77c3f15f9f976d6668a1b1fcefb744b7b5a8840567a24d8a695305171adc1f05c31c1357b13f87363e7e268bc672e002c8
7
+ data.tar.gz: 5f3be74d4dfb774a878f9b6e45421777ca1dfec9c117ef864ffb8183b96fde9c8c33ceda0a2ec75cbf0b020143060f382c244064c7d5e3db24ab032db5b397d4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
1
  # CHANGELOG
2
2
 
3
3
  ## master
4
+
5
+ ## 0.1.1
6
+
7
+ Updating integration with `rodauth-i18n`, which changed the setup for `v0.2.0`.
8
+
9
+ ## 0.1.0
10
+
11
+ Support for internationalization (I18n) by hooking up with [rodauth-i18n](https://github.com/janko/rodauth-i18n). Shipping translation for english under `locales/` dir.
12
+
13
+ ## 0.0.4
14
+
15
+ Cookies used for selected account are now secure by default (httponly on, secure if request is TLS-enabled);
16
+
17
+ Cookie path is now "/" by default.
18
+
19
+ ## 0.0.3
20
+
21
+ bugfix: fixing calls to the view helpers when in multi-phase login mode.
22
+
23
+ ## 0.0.2
24
+
25
+ bugfix: added missing form templates.
26
+
27
+ ## 0.0.1
28
+
29
+ Initial draft, all features added.
data/README.md CHANGED
@@ -110,7 +110,7 @@ The following options and methods are also available to override, and names shou
110
110
  * `add_account_redirect`
111
111
  * `select_account_notice_flash`
112
112
  * `select_account_error_flash`
113
- * `require_select_account_error_flash
113
+ * `require_select_account_error_flash`
114
114
  * `before_select_account_route`
115
115
  * `before_select_account`
116
116
  * `after_select_account`
@@ -125,9 +125,17 @@ These are also available methods:
125
125
  * `accounts_in_session`: returns all the available accounts in session
126
126
  * `require_select_account`: to be used like `require_account`, as a filter to actions that require a user to explicitly select an account before allowing it.
127
127
 
128
+ #### Internationalization (i18n)
129
+
130
+ `rodauth-select-account` supports translating all user-facing text found in all pages and forms and buttons, by integrating with [rodauth-i18n](https://github.com/janko/rodauth-i18n). Just set it up in your application and `rodauth` configuration.
131
+
132
+ Default translations shipping with `rodauth-select-account` can be found [in this directory](https://gitlab.com/honeyryderchuck/rodauth-select-account/-/tree/master/locales). If they're not available for the languages you'd like to support, consider getting them translated from the english text, and contributing them to this repository via a Merge Request.
133
+
134
+ (This feature is available since `v0.1`.)
135
+
128
136
  ## Ruby support policy
129
137
 
130
- The minimum Ruby version required to run `rodauth-select-account` is 2.4 . Besides that, it should support all rubies that rodauth and roda support, including JRuby and (potentially, I don't know yet) truffleruby.
138
+ The minimum Ruby version required to run `rodauth-select-account` is 2.4 . Besides that, it supports all rubies that rodauth and roda support, including JRuby and truffleruby.
131
139
 
132
140
  ## Development
133
141
 
@@ -136,4 +144,3 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
136
144
  ## Contributing
137
145
 
138
146
  Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/honeyryderchuck/rodauth-select-account.
139
-
@@ -54,15 +54,18 @@ module Rodauth
54
54
  def require_select_account
55
55
  # whether an account has been selected for a certain workflow will be driven by a short-lived
56
56
  # cookie, which will hopefully be active during the duration of account selection
57
+ opts = Hash[accounts_cookie_options]
58
+ opts[:path] = "/" unless opts.key?(:path)
57
59
  if request.cookies[require_selected_account_cookie_key]
58
- ::Rack::Utils.delete_cookie_header!(response.headers, require_selected_account_cookie_key)
60
+ ::Rack::Utils.delete_cookie_header!(response.headers, require_selected_account_cookie_key, opts)
59
61
  return
60
62
  end
61
63
 
62
- opts = {
63
- value: true,
64
- expires: Time.now + require_selected_account_cookie_interval
65
- }
64
+ opts[:value] = true
65
+ opts[:expires] = Time.now + require_selected_account_cookie_interval
66
+ opts[:httponly] = true unless opts.key?(:httponly)
67
+ opts[:secure] = true unless opts.key?(:secure) || !request.ssl?
68
+
66
69
  ::Rack::Utils.set_cookie_header!(response.headers, require_selected_account_cookie_key, opts)
67
70
 
68
71
  # should redirect to the accounts page, and set this as the page to return to
@@ -80,6 +83,11 @@ module Rodauth
80
83
  true
81
84
  end
82
85
 
86
+ def post_configure
87
+ super
88
+ i18n_register(File.expand_path(File.join(__dir__, "..", "..", "..", "locales"))) if features.include?(:i18n)
89
+ end
90
+
83
91
  private
84
92
 
85
93
  # when selecting an account and requiring login, you'll want the user to go back to where it was
@@ -170,6 +178,9 @@ module Rodauth
170
178
  opts = Hash[accounts_cookie_options]
171
179
  opts[:value] = accounts_cookie.join(",")
172
180
  opts[:expires] = Time.now + accounts_cookie_interval
181
+ opts[:path] = "/" unless opts.key?(:path)
182
+ opts[:httponly] = true unless opts.key?(:httponly)
183
+ opts[:secure] = true unless opts.key?(:secure) || !request.ssl?
173
184
  ::Rack::Utils.set_cookie_header!(response.headers, accounts_cookie_key, opts)
174
185
  end
175
186
 
@@ -229,7 +240,7 @@ module Rodauth
229
240
  r.post do
230
241
  # This is a copy of the login routine
231
242
  skip_error_flash = false
232
- view = :add_account
243
+ view = :add_account_view
233
244
 
234
245
  catch_error do
235
246
  # this instruction will load the new account
@@ -268,7 +279,7 @@ module Rodauth
268
279
  end
269
280
 
270
281
  set_error_flash add_account_error_flash unless skip_error_flash
271
- send("#{view}_view")
282
+ send(view)
272
283
  end
273
284
  end
274
285
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rodauth
4
4
  module SelectAccount
5
- VERSION = "0.0.2"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
data/locales/en.yml ADDED
@@ -0,0 +1,12 @@
1
+ en:
2
+ rodauth:
3
+ add_account_notice_flash: "You have added a new account"
4
+ add_account_error_flash: "There was an error adding the new account"
5
+ require_add_account_error_flash: "Please add account to continue"
6
+ add_account_page_title: "Add Account"
7
+ add_account_button: "Add Account"
8
+ select_account_notice_flash: "You have selected an account"
9
+ select_account_error_flash: "There was an error selecting the account"
10
+ require_select_account_error_flash: "Please select account to continue"
11
+ select_account_page_title: "Select Account"
12
+ no_account_message: "could not select account"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-select-account
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-20 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rodauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  description: Multiple authenticated accounts per session in rodauth.
14
28
  email:
15
29
  - cardoso_tiago@hotmail.com
@@ -26,6 +40,7 @@ files:
26
40
  - lib/rodauth/features/select_account.rb
27
41
  - lib/rodauth/select-account.rb
28
42
  - lib/rodauth/select-account/version.rb
43
+ - locales/en.yml
29
44
  - templates/add-account-form.str
30
45
  - templates/add-account.str
31
46
  - templates/select-account.str
@@ -50,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
65
  - !ruby/object:Gem::Version
51
66
  version: '0'
52
67
  requirements: []
53
- rubygems_version: 3.1.2
68
+ rubygems_version: 3.2.22
54
69
  signing_key:
55
70
  specification_version: 4
56
71
  summary: Multiple authenticated accounts per session in rodauth.