rodauth-rails 1.5.1 → 1.5.2

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: 496b2621170adf123079ae52341d3f6d0b3a120c3fa9f81e1bd26886735c6808
4
- data.tar.gz: eb1001f7835561714a134649b989c9cb0f09a5091e4b8d009650134f03d60470
3
+ metadata.gz: 4d36f5274c33c95aab970521c38b77e9ac47242cc248e181f122b8ef518e5017
4
+ data.tar.gz: d52e7ec12ebde869a023d6123b5550b061bb4210bc44bd4f4fa8200e592cf94d
5
5
  SHA512:
6
- metadata.gz: e6681a10e0d724656c2b27be02a59eebc107f8a13ebf39b5732696da9df6c6631fe8ac23601db12bb568923b339ee790800b96bb3a3c71a9978c8aa02becea9d
7
- data.tar.gz: e802cd53015dc736395e5cdf1e7f2df3cb0174075da18af1ca5317867e33ad79d695c7d01d22acc2f581d33b578c2da88af0c91259db79bae85183a9316a2334
6
+ metadata.gz: f8162dd61a98976e3b06d6cee8575197f284e3415c8edcfa30ceed005fbedfe18f3d1c739253ce967434c35dc1ce01b246bd535069daaec92d71c807f2c91ac5
7
+ data.tar.gz: cb6fe07c7cdb2a7d310ec1dcd60f35170fc478230b33d8cb193797b4db824c519ac4f2de588ff2f176ca96b7746ea7573a116e4497436eccaa640f073c8927ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.5.2 (2022-07-03)
2
+
3
+ * Bump Rodauth dependency version to 2.25+ (@janko)
4
+
5
+ * Generate fixture file for accounts on `rodauth:install` (@benkoshy)
6
+
7
+ * Fix error about undefined `controller_path` method in `newrelic_rpm` gem instrumentation (@janko)
8
+
9
+ * Don't display disabled routes in `rodauth:routes` (@janko)
10
+
11
+ * Display HTTP verbs of endpoints in `rodauth:routes` rake task (@janko)
12
+
1
13
  ## 1.5.1 (2022-06-19)
2
14
 
3
15
  * Fix syntax for creating `citext` PG extension in Sequel base migration (@Empact)
data/README.md CHANGED
@@ -110,18 +110,18 @@ $ rails rodauth:routes
110
110
  ```
111
111
  Routes handled by RodauthApp:
112
112
 
113
- /login rodauth.login_path
114
- /create-account rodauth.create_account_path
115
- /verify-account-resend rodauth.verify_account_resend_path
116
- /verify-account rodauth.verify_account_path
117
- /change-password rodauth.change_password_path
118
- /change-login rodauth.change_login_path
119
- /logout rodauth.logout_path
120
- /remember rodauth.remember_path
121
- /reset-password-request rodauth.reset_password_request_path
122
- /reset-password rodauth.reset_password_path
123
- /verify-login-change rodauth.verify_login_change_path
124
- /close-account rodauth.close_account_path
113
+ GET/POST /login rodauth.login_path
114
+ GET/POST /create-account rodauth.create_account_path
115
+ GET/POST /verify-account-resend rodauth.verify_account_resend_path
116
+ GET/POST /verify-account rodauth.verify_account_path
117
+ GET/POST /change-password rodauth.change_password_path
118
+ GET/POST /change-login rodauth.change_login_path
119
+ GET/POST /logout rodauth.logout_path
120
+ GET/POST /remember rodauth.remember_path
121
+ GET/POST /reset-password-request rodauth.reset_password_request_path
122
+ GET/POST /reset-password rodauth.reset_password_path
123
+ GET/POST /verify-login-change rodauth.verify_login_change_path
124
+ GET/POST /close-account rodauth.close_account_path
125
125
  ```
126
126
 
127
127
  Using this information, you can add some basic authentication links to your
@@ -381,6 +381,7 @@ class RodauthController < ApplicationController
381
381
  when rodauth.login_path,
382
382
  rodauth.create_account_path,
383
383
  rodauth.verify_account_path,
384
+ rodauth.verify_account_resend_path,
384
385
  rodauth.reset_password_path,
385
386
  rodauth.reset_password_request_path
386
387
  "authentication"
@@ -70,6 +70,13 @@ module Rodauth
70
70
  end
71
71
  end
72
72
 
73
+ def create_fixtures
74
+ test_unit_options = ::Rails.application.config.generators.options[:test_unit]
75
+ if test_unit_options[:fixture] && test_unit_options[:fixture_replacement].nil?
76
+ template "app/test/fixtures/accounts.yml"
77
+ end
78
+ end
79
+
73
80
  def show_instructions
74
81
  readme "INSTRUCTIONS" if behavior == :invoke
75
82
  end
@@ -0,0 +1,10 @@
1
+ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+ one:
3
+ email: freddie@queen.com
4
+ password_hash: <%%= BCrypt::Password.create("password", cost: BCrypt::Engine::MIN_COST) %>
5
+ status: 2
6
+
7
+ two:
8
+ email: brian@queen.com
9
+ password_hash: <%%= BCrypt::Password.create("password", cost: BCrypt::Engine::MIN_COST) %>
10
+ status: 2
@@ -59,6 +59,12 @@ module Rodauth
59
59
  rodauth(name) or fail ArgumentError, "unknown rodauth configuration: #{name.inspect}"
60
60
  end
61
61
 
62
+ # The newrelic_rpm gem expects this when we pass the roda class as
63
+ # :controller in instrumentation payload.
64
+ def self.controller_path
65
+ name.underscore
66
+ end
67
+
62
68
  module RequestMethods
63
69
  def rodauth(name = nil)
64
70
  prefix = scope.rodauth(name).prefix
@@ -32,7 +32,7 @@ module Rodauth
32
32
  request = rails_request
33
33
 
34
34
  raw_payload = {
35
- controller: scope.class.superclass.name,
35
+ controller: self.class.roda_class.name,
36
36
  action: "call",
37
37
  request: request,
38
38
  params: request.filtered_parameters,
@@ -6,20 +6,34 @@ namespace :rodauth do
6
6
 
7
7
  app.opts[:rodauths].each do |configuration_name, auth_class|
8
8
  rodauth = auth_class.allocate
9
+ only_json = rodauth.method(:only_json?).owner != Rodauth::Base && rodauth.only_json?
10
+
11
+ routes = auth_class.route_hash.map do |path, handle_method|
12
+ file_path, start_line = rodauth.method(:"_#{handle_method}").source_location
13
+ lines = File.foreach(file_path).to_a
14
+ indentation = lines[start_line - 1][/^\s+/]
15
+ verbs = []
16
+
17
+ lines[start_line..-1].each do |code|
18
+ verbs << :GET if code.include?("r.get") && !only_json
19
+ verbs << :POST if code.include?("r.post")
20
+ break if code.start_with?("#{indentation}end")
21
+ end
9
22
 
10
- routes = auth_class.routes.map do |handle_method|
11
23
  path_method = "#{handle_method.to_s.sub(/\Ahandle_/, "")}_path"
12
24
 
13
25
  [
14
- rodauth.public_send(path_method),
26
+ verbs.join("/"),
27
+ "#{rodauth.prefix}#{path}",
15
28
  "rodauth#{configuration_name && "(:#{configuration_name})"}.#{path_method}",
16
29
  ]
17
30
  end
18
31
 
19
- padding = routes.map { |path, _| path.length }.max
32
+ verbs_padding = routes.map { |verbs, _, _| verbs.length }.max
33
+ path_padding = routes.map { |_, path, _| path.length }.max
20
34
 
21
- route_lines = routes.map do |path, code|
22
- "#{path.ljust(padding)} #{code}"
35
+ route_lines = routes.map do |verbs, path, code|
36
+ "#{verbs.ljust(verbs_padding)} #{path.ljust(path_padding)} #{code}"
23
37
  end
24
38
 
25
39
  puts "\n #{route_lines.join("\n ")}" unless route_lines.empty?
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "1.5.1"
3
+ VERSION = "1.5.2"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency "railties", ">= 4.2", "< 8"
20
- spec.add_dependency "rodauth", "~> 2.23"
20
+ spec.add_dependency "rodauth", "~> 2.25"
21
21
  spec.add_dependency "roda", "~> 3.55"
22
22
  spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
23
23
  spec.add_dependency "rodauth-model", "~> 0.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-19 00:00:00.000000000 Z
11
+ date: 2022-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.23'
39
+ version: '2.25'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.23'
46
+ version: '2.25'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: roda
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -224,6 +224,7 @@ files:
224
224
  - lib/generators/rodauth/templates/app/misc/rodauth_app.rb
225
225
  - lib/generators/rodauth/templates/app/misc/rodauth_main.rb
226
226
  - lib/generators/rodauth/templates/app/models/account.rb
227
+ - lib/generators/rodauth/templates/app/test/fixtures/accounts.yml
227
228
  - lib/generators/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb
228
229
  - lib/generators/rodauth/templates/app/views/rodauth/_login_form.html.erb
229
230
  - lib/generators/rodauth/templates/app/views/rodauth/_login_form_footer.html.erb