rodauth-select-account 0.0.1 → 0.1.0

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: 9496ecf9a3647c6371feef06b8cb81403ff9c076012650f740778f246b66180e
4
- data.tar.gz: aeb014bfa0376f53fc34bc4fe7870fc4ac23b080da8b8ce11457c3ca43404765
3
+ metadata.gz: e1268790cfe1720860c39c93bced3253c0cb1bf83dacec424d21cf7facd2f0a3
4
+ data.tar.gz: d161bade62b8e1b935fb192ebec45d3641b546b4cf52896cccc3f225a01450ca
5
5
  SHA512:
6
- metadata.gz: ea5fb45c7bf98c22827756fc9c5b0f684f7a76be9843a1f0a46d0d4088f2f4957161b562b1c4c1fb91ff952e4783f6cde6cdccd456401fb51281a25486e9d317
7
- data.tar.gz: 66e79a5a50fc9df83aa63228b8079df3cbee160e56f23c05e84efbb2201c9c1400c48e7eabd9c788d602946aa15e3aa8f215c6519601a9ceb6cfcf9d8c8e2b7b
6
+ metadata.gz: cd003394cba3aaad1c103ffae1dd008cea6e3788cb9cd96636074021854891a20d2c9d43f83351ba938cd78b923fab171de7d31609d32638a18a0c2202b139d0
7
+ data.tar.gz: c489337600b4e06912ecf4e650dcf4b58b2ad69524d9acbe6cbe45df6ab8a1c75faa8b23481456eac12b6d4d42fb19779f2b22934e2ac175a84db597b61a687a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
1
  # CHANGELOG
2
2
 
3
3
  ## master
4
+
5
+ ## 0.1.0
6
+
7
+ Support for internationalization (I18n) by hooking up with [rodauth-i18n](https://github.com/janko/rodauth-i18n). Shipping translation for english under `locales/` dir.
8
+
9
+ ## 0.0.4
10
+
11
+ Cookies used for selected account are now secure by default (httponly on, secure if request is TLS-enabled);
12
+
13
+ Cookie path is now "/" by default.
14
+
15
+ ## 0.0.3
16
+
17
+ bugfix: fixing calls to the view helpers when in multi-phase login mode.
18
+
19
+ ## 0.0.2
20
+
21
+ bugfix: added missing form templates.
22
+
23
+ ## 0.0.1
24
+
25
+ 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
@@ -170,6 +173,9 @@ module Rodauth
170
173
  opts = Hash[accounts_cookie_options]
171
174
  opts[:value] = accounts_cookie.join(",")
172
175
  opts[:expires] = Time.now + accounts_cookie_interval
176
+ opts[:path] = "/" unless opts.key?(:path)
177
+ opts[:httponly] = true unless opts.key?(:httponly)
178
+ opts[:secure] = true unless opts.key?(:secure) || !request.ssl?
173
179
  ::Rack::Utils.set_cookie_header!(response.headers, accounts_cookie_key, opts)
174
180
  end
175
181
 
@@ -229,7 +235,7 @@ module Rodauth
229
235
  r.post do
230
236
  # This is a copy of the login routine
231
237
  skip_error_flash = false
232
- view = :add_account
238
+ view = :add_account_view
233
239
 
234
240
  catch_error do
235
241
  # this instruction will load the new account
@@ -268,7 +274,7 @@ module Rodauth
268
274
  end
269
275
 
270
276
  set_error_flash add_account_error_flash unless skip_error_flash
271
- send("#{view}_view")
277
+ send(view)
272
278
  end
273
279
  end
274
280
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rodauth
4
4
  module SelectAccount
5
- VERSION = "0.0.1"
5
+ VERSION = "0.1.0"
6
6
  end
7
7
  end
@@ -3,3 +3,5 @@
3
3
  require "rodauth"
4
4
 
5
5
  require "rodauth/select-account/version"
6
+
7
+ Rodauth::I18n.directories << File.expand_path(File.join(__dir__, "..", "..", "locales")) if defined?(Rodauth::I18n)
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"
@@ -0,0 +1,6 @@
1
+ <form method="post" class="rodauth" role="form" id="add-account-form">
2
+ #{rodauth.csrf_tag}
3
+ #{rodauth.skip_login_field_on_login? ? rodauth.render('login-display') : rodauth.render('login-field')}
4
+ #{rodauth.render('password-field') unless rodauth.skip_password_field_on_login?}
5
+ #{rodauth.button(rodauth.add_account_button)}
6
+ </form>
@@ -0,0 +1,3 @@
1
+ #{rodauth.login_form_header}
2
+ #{rodauth.render('add-account-form')}
3
+ #{rodauth.login_form_footer}
@@ -0,0 +1,17 @@
1
+ <div class="list-group">
2
+ #{
3
+ rodauth.accounts_in_session.map do |account|
4
+ next if account[rodauth.account_id_column] == rodauth.session_value
5
+
6
+ <<-OUT
7
+ <form method="post" class="rodauth" role="form" id="select-account-form">
8
+ #{rodauth.csrf_tag}
9
+ <input type="hidden" name="#{rodauth.login_param}" value="#{account[rodauth.login_column]}" />
10
+ <button type="submit" class="list-group-item list-group-item-action">
11
+ #{account[rodauth.login_column]}
12
+ </button>
13
+ </form>
14
+ OUT
15
+ end.join
16
+ }
17
+ </div>
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.1
4
+ version: 0.1.0
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-02 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,10 @@ 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
44
+ - templates/add-account-form.str
45
+ - templates/add-account.str
46
+ - templates/select-account.str
29
47
  homepage: https://gitlab.com/honeyryderchuck/rodauth-select-account
30
48
  licenses: []
31
49
  metadata:
@@ -47,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
65
  - !ruby/object:Gem::Version
48
66
  version: '0'
49
67
  requirements: []
50
- rubygems_version: 3.1.2
68
+ rubygems_version: 3.2.22
51
69
  signing_key:
52
70
  specification_version: 4
53
71
  summary: Multiple authenticated accounts per session in rodauth.