b4um_generators 0.5.0 → 0.5.1

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: 32be49cb4a38e8c75eba464939aa99d73d45784f0434d3aa75f0b4d7fd57862f
4
- data.tar.gz: a3af1d5dcb53dd3aa945f92f05ec84bdb271c0a6ffc14fb1c99c96232d7a6407
3
+ metadata.gz: 6be3f0b7860fd76276d56a1656a8cbf149d590d9684f16bc8b208ed1aa9adbc7
4
+ data.tar.gz: 139cf83e17e3164c3a83cbcd3c6fbe0c3101932faa86d8e0922c389f7e4013b1
5
5
  SHA512:
6
- metadata.gz: c00cf8cab52aa8f5edf31b01ac68e948c2f8019ba2978542546be8daa79a138c40673b421c82ba5933e51553b781fbd700fcac3857d973b3da13816904e20b90
7
- data.tar.gz: d9b452a787712782c27a4a02799cac27b0ee2566bb97bb8e14875fe521e89a17eb2632873a5c772385e78264abf0204a3dba696b37c830e20d911c01ae17b220
6
+ metadata.gz: df66e4e64b8c164ba7672239eafd2e4e3fc477498966130c0afa8d7d536602a0373b7f45bb265f26698d2aa4d3085db98551aa5062071c471ca4d3a993b70a39
7
+ data.tar.gz: 8cdaed723ccfde18308962ac754c6a493d26b6be6ea7da3ec9b37904a7842be3969a550c8b025763933a997b641428fe0d952660d04f227eaec04538d708672c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ All notable changes to b4um Generators will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.1] - 2026-10-14
8
+
9
+ ### Added
10
+
11
+ - Added optional `--login-path` configuration to the Todo generator
12
+ - Added validation for custom login route helpers
13
+ - Added RSpec coverage for default, custom and invalid login routes
14
+
15
+ ### Fixed
16
+
17
+ - Fixed unauthenticated access to personal Todo lists by redirecting users to the login page instead of returning HTTP
18
+ 401
19
+ - Preserved public Todo list access without authentication requirements
20
+
21
+ ### Changed
22
+
23
+ - Kept `login_path` as the default route for b4um authentication
24
+ - Updated English and German README documentation
25
+ - Verified the complete generator suite with 507 RSpec examples and 0 failures
26
+
7
27
  ## [0.5.0] - 2026-10-14
8
28
 
9
29
  ### Added
data/README.de.md CHANGED
@@ -24,7 +24,7 @@ b4um Generators wird während der Entwicklung derzeit als lokales Gem verwendet.
24
24
  Füge das Gem zur `Gemfile` der Rails-Anwendung hinzu:
25
25
 
26
26
  ```ruby
27
- gem "b4um_generators", "~> 0.5.0", path: "/pfad/zu/b4um_generators"
27
+ gem "b4um_generators", "~> 0.5.1", path: "/pfad/zu/b4um_generators"
28
28
  ```
29
29
 
30
30
  Führe anschließend aus:
@@ -1204,7 +1204,20 @@ Wird ein Eigentümermodell angegeben, erhält jedes angemeldete Benutzerkonto se
1204
1204
  Die Aufgaben werden über die Verknüpfung des aktuell angemeldeten Kontos geladen. Dadurch können Benutzer nicht auf
1205
1205
  Aufgaben anderer Konten zugreifen.
1206
1206
 
1207
- Nicht authentifizierte Anfragen an benutzerspezifische Todo-Aktionen erhalten den HTTP-Status `401 Unauthorized`.
1207
+ Nicht angemeldete Benutzer werden automatisch zur Login-Seite weitergeleitet.
1208
+
1209
+ Standardmäßig verwendet der Generator den Route-Helper `login_path` aus dem b4um-Authentifizierungssystem.
1210
+
1211
+ Optional kann eine andere Login-Route angegeben werden:
1212
+
1213
+ ```bash
1214
+ bin/rails generate b4um:todo Task --owner=User --login-path=new_user_session_path
1215
+ ```
1216
+
1217
+ Die Option `--login-path` ist freiwillig. Wird sie nicht angegeben, verwendet der Generator automatisch `login_path`.
1218
+
1219
+ Öffentliche Todo-Listen, die ohne `--owner` erstellt werden, benötigen keine Anmeldung und leiten Benutzer nicht zur
1220
+ Login-Seite weiter.
1208
1221
 
1209
1222
  ### Integration mit der Authentifizierung
1210
1223
 
@@ -1663,7 +1676,7 @@ wird.
1663
1676
 
1664
1677
  ## Version
1665
1678
 
1666
- Aktuelle Version: `0.5.0`
1679
+ Aktuelle Version: `0.5.1`
1667
1680
 
1668
1681
  ## Autor
1669
1682
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ b4um Generators is currently used as a local gem during development.
23
23
  Add the gem to the Rails application's `Gemfile`:
24
24
 
25
25
  ```ruby
26
- gem "b4um_generators", "~> 0.5.0", path: "/path/to/b4um_generators"
26
+ gem "b4um_generators", "~> 0.5.1", path: "/path/to/b4um_generators"
27
27
  ```
28
28
 
29
29
  Then run:
@@ -1183,7 +1183,19 @@ When an owner is configured, each authenticated account has its own Todo list.
1183
1183
  Tasks are loaded through the current owner's association, preventing users from accessing tasks belonging to another
1184
1184
  account.
1185
1185
 
1186
- Unauthenticated requests to owner-specific Todo actions receive HTTP `401 Unauthorized`.
1186
+ Unauthenticated users are automatically redirected to the login page.
1187
+
1188
+ By default, the generator uses the `login_path` route helper provided by the b4um authentication system.
1189
+
1190
+ You can optionally specify a different login route:
1191
+
1192
+ ```bash
1193
+ bin/rails generate b4um:todo Task --owner=User --login-path=new_user_session_path
1194
+ ```
1195
+
1196
+ The `--login-path` option is optional. If omitted, `login_path` is used.
1197
+
1198
+ Public Todo lists generated without `--owner` do not require authentication and do not redirect users to a login page.
1187
1199
 
1188
1200
  ### Authentication Integration
1189
1201
 
@@ -1638,7 +1650,7 @@ The gem can be tested locally by referencing the repository with `path:` from a
1638
1650
 
1639
1651
  ## Version
1640
1652
 
1641
- Current version: `0.5.0`
1653
+ Current version: `0.5.1`
1642
1654
 
1643
1655
  ## Author
1644
1656
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module B4umGenerators
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
@@ -184,7 +184,8 @@ class <%= class_name.pluralize %>Controller < ApplicationController
184
184
  def require_todo_owner
185
185
  return if <%= current_owner_method %>
186
186
 
187
- head :unauthorized
187
+ redirect_to <%= options[:login_path] %>,
188
+ alert: "Bitte melde dich an, um deine Aufgaben zu verwalten."
188
189
  end
189
190
  <% end %>
190
191
  end
@@ -15,6 +15,11 @@ module B4um
15
15
  default: nil,
16
16
  desc: "Associates tasks with the specified owner model."
17
17
 
18
+ class_option :login_path,
19
+ type: :string,
20
+ default: "login_path",
21
+ desc: "Route helper for unauthenticated users (default: login_path)."
22
+
18
23
  class << self
19
24
  def desc(_description = nil)
20
25
  "Creates a complete To-Do list with Turbo and Stimulus."
@@ -32,6 +37,17 @@ module B4um
32
37
  "Invalid owner model: #{owner_name}"
33
38
  end
34
39
 
40
+ def validate_login_path
41
+ return unless owner?
42
+
43
+ login_route = options[:login_path].to_s
44
+
45
+ return if login_route.match?(/\A[a-z_][a-zA-Z0-9_]*_path\z/)
46
+
47
+ raise Thor::Error,
48
+ "Invalid login path: #{login_route}. Expected a Rails route helper ending in _path."
49
+ end
50
+
35
51
  def create_todo_migration
36
52
  return if todo_migration_exists?
37
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: b4um_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Baum