Commit 045a952
authored
FIX: login redirect to root path in subfolder setup (#36609)
When Discourse is served from a subfolder (e.g., /forum), logging in
from the login page itself would incorrectly redirect users to the root
domain (/) instead of the subfolder root (/forum/).
The issue had two causes:
1. The login path check in `extract_redirect_param` used the Rails
`login_path` helper which returns "/login" without the subfolder prefix.
When the browser sent the full path "/forum/login", the check
`starts_with?("/login")` failed to match, treating it as a valid
redirect target instead of rejecting it.
2. The `enter` method didn't apply the subfolder prefix when falling
back to the root path "/".
Fixed by:
- Building the full login path with `Discourse.base_path` for accurate
matching in subfolder setups
- Wrapping the fallback "/" with `path()` in `enter` to respect the
subfolder configuration
- Extracting redirect validation into `valid_redirect_uri?` for clarity
Ref - meta/t/3866191 parent 58d298c commit 045a952
File tree
2 files changed
+43
-16
lines changed- app/controllers
- spec/requests
2 files changed
+43
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 31 | + | |
36 | 32 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 33 | + | |
| 34 | + | |
45 | 35 | | |
| 36 | + | |
| 37 | + | |
46 | 38 | | |
47 | 39 | | |
48 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | | - | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
| 163 | + | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
399 | 424 | | |
400 | 425 | | |
401 | 426 | | |
| |||
0 commit comments