Closed mcvmcv closed 1 year ago
@mcvmcv thanks for flagging this - can you share the app as a zip file to make it easier to debug?
@mcvmcv Judging by the warning it looks like there is no show_login
route - which is supposed to display the login form.
WatchTonight.zip App should be attached. I have made no migrations, so logging in is not possible.
The :show_login
route definitely exists: you can access it by visiting /test
or /test2
; or /test_movies
after editing the controller function while the server is running.
Here is a shell session I just ran:
me@pc:~/projects/Watchtonight$ bin/server
_____ _
| __|___ ___|_|___
| | | -_| | | -_|
|_____|___|_|_|_|___|
| Web: https://genieframework.com
| GitHub: https://github.com/genieframework/Genie.jl
| Docs: https://www.genieframework.com/docs/tutorials/Overview.html
| Discord: https://discord.com/invite/9zyZbD6J7H
| Twitter: https://twitter.com/GenieMVC
Active env: DEV
Loading plugins[ Info: 2022-02-15 07:43:37 Precompiling AuthenticationController [top-level]
Ready!
┌ Info: 2022-02-15 07:44:03
└ Web Server starting at http://127.0.0.1:8000 - press Ctrl/Cmd+C to stop the server.
[ Info: 2022-02-15 07:44:25 GET /login 200
[ Info: 2022-02-15 07:44:37 SELECT "users"."id" AS "users_id", "users"."username" AS "users_username", "users"."password" AS "users_password", "users"."name" AS "users_name", "users"."email" AS "users_email" FROM "users" WHERE "id" = NULL ORDER BY users.id ASC
current_user() = nothing
[ Info: 2022-02-15 07:44:38 GET /test 302 # This route calls `@authenticated!` from `routes.jl`
[ Info: 2022-02-15 07:44:38 GET /login 200
[ Info: 2022-02-15 07:44:53 GET /test2 302 # This route calls `@authenticated!` from `routes.jl`
[ Info: 2022-02-15 07:44:53 GET /login 200
[ Info: 2022-02-15 07:45:03 GET /test_movies 302 # This route calls `@authenticated!` from MoviesController.jl
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302
[ Info: 2022-02-15 07:45:03 GET /test_movies 302 #The browser gave up here and displayed a warning here.
[ Info: 2022-02-15 07:45:44 GET /test_movies 302 #Here I have edited the controller function, and refreshing redirects correctly to the login page.
[ Info: 2022-02-15 07:45:44 GET /test_movies 302
[ Info: 2022-02-15 07:45:44 GET /login 200
@mcvmcv thank you! I'll try to debug it today and follow up.
I'm having the same issue as @mcvmcv
I'm getting a 302 error from trying to access a route that calls the @authenticated!
macro, it only happens if I'm not logged in.
If I navigate to the :show_login
route manually and log in, then navigate to the authentication restricted route everything seems to work properly.
@MRoqueta - thanks, I haven't had the chance to look into it but I'll try to soon, we'll need a fresh release and some refactoring of the package, so it would be a good opportunity.
Confirmed issue with the @authenticated!
macro and the not found route. The macro was evaluated before the route was loaded so it didn't know where to correctly redirect.
This has been addressed in v2.1 -- the @authenticated!
macro should be replaced with the authenticated!()
function.
According to the documentation in the readme at https://github.com/GenieFramework/GenieAuthentication.jl, there are two main ways to use the GenieAuthentication
@authenticated!
macro: 1/ Inroutes.jl
:2/ In a controller file:
I am finding that only the first works correctly.
To reproduce: Construct a minimal WatchTonight style app with GenieAuthentication.
In
routes.jl
and in MoviesController.jl:
Then
/test
and/test2
show the current user (here,nothing
) in the repl and redirect to login as expected, while/test_movies
continually redirects to itself before giving up.Additional information: The first time loading this project I got:
This line about
show_login
not being defined didn't appear on subsequentbin/server
commands.While running the server, editing the
MoviesController.test_movies
function (causing recompilation?) means that/test_movies
redirects to/login
correctly.Routes like
/test
and/test2
above can use thecurrent_user()
function defined in/plugins/genie_authentication.jl
, while/test_movies
cannot find it.Versions, packages, etc: