GenieFramework / GenieAuthentication.jl

Authentication plugin for Genie framework
MIT License
20 stars 11 forks source link

GenieAuthentication fails to create controller #19

Closed Sov-trotter closed 1 year ago

Sov-trotter commented 1 year ago

I now understand that the issue https://github.com/GenieFramework/Genie.jl/issues/554 might have been partly caused by GenieAuthenticator.

I followed the steps in the readme. Somehow the modules like Users, AuthenticationController are not loaded into the scope.

ulia> using Genie

julia> Genie.Generator.newapp_mvc("AuthApp")

Please choose the DB backend you want to use: 
1. SQLite
2. MySQL
3. PostgreSQL
4. Skip installing DB support at this time

Input 1, 2, 3 or 4 and press ENTER to confirm.
If you are not sure what to pick, choose 1 (SQLite). It is the simplest option to get you started right away.
You can add support for additional databases anytime later. 

1
  Activating project at `~/.julia/dev`
[ Info: Done! New app created at /home/ezio/.julia/dev/AuthApp
[ Info: Changing active directory to /home/ezio/.julia/dev/AuthApp
    /tmp/jl_Rra9Xl/AuthApp/Project.toml
[ Info: Project.toml has been generated
[ Info: Installing app dependencies
  Activating project at `~/.julia/dev/AuthApp`
  Activating project at `~/.julia/dev/AuthApp`
[ Info: Installing dependencies for unit tests
  Activating new project at `~/.julia/dev/AuthApp/test`
  Activating project at `~/.julia/dev/AuthApp`
  Activating project at `~/.julia/dev/AuthApp`
[ Info: Starting your brand new Genie app - hang tight!
[ Info: Precompiling AuthApp [c510d05b-871a-4c8f-84d0-25ab9f17f1cb]

 ██████╗ ███████╗███╗   ██╗██╗███████╗    ███████╗
██╔════╝ ██╔════╝████╗  ██║██║██╔════╝    ██╔════╝
██║  ███╗█████╗  ██╔██╗ ██║██║█████╗      ███████╗
██║   ██║██╔══╝  ██║╚██╗██║██║██╔══╝      ╚════██║
╚██████╔╝███████╗██║ ╚████║██║███████╗    ███████║
 ╚═════╝ ╚══════╝╚═╝  ╚═══╝╚═╝╚══════╝    ╚══════╝

| Website  https://genieframework.com
| GitHub   https://github.com/genieframework
| Docs     https://genieframework.com/docs
| Discord  https://discord.com/invite/9zyZbD6J7H
| Twitter  https://twitter.com/essenciary

Active env: DEV

Ready! 

┌ Info: 2022-08-02 09:48:31 
└ Web Server starting at http://127.0.0.1:8000 

julia> include(joinpath("config", "initializers", "searchlight.jl"))
SQLite.DB("db/dev.sqlite3")

julia> include(joinpath("config", "initializers", "searchlight.jl"))
SQLite.DB("db/dev.sqlite3")

julia> SearchLight.Migration.init()
┌ Info: 2022-08-02 09:49:16 CREATE TABLE `schema_migrations` (
│       `version` varchar(30) NOT NULL DEFAULT '',
│       PRIMARY KEY (`version`)
└     )
[ Info: 2022-08-02 09:49:16 Created table schema_migrations

(AuthApp) pkg> add GenieAuthentication
   Resolving package versions...
    Updating `~/.julia/dev/AuthApp/Project.toml`
  [e115e502] + GenieAuthentication v2.0.0
    Updating `~/.julia/dev/AuthApp/Manifest.toml`
  [e115e502] + GenieAuthentication v2.0.0
  [07906039] + GeniePlugins v1.0.0
  [03cc5b98] + GenieSession v1.0.0
  [5c4fdc26] + GenieSessionFileSession v1.0.0

julia> using GenieAuthentication

julia> GenieAuthentication.install(@__DIR__)
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/app
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/app/resources
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/app/resources/authentication
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/authentication/AuthenticationController.jl to /home/ezio/.julia/dev/AuthApp/app/resources/authentication/AuthenticationController.jl
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/app/resources/authentication/views
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/authentication/views/login.jl.html to /home/ezio/.julia/dev/AuthApp/app/resources/authentication/views/login.jl.html
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/authentication/views/register.jl.html to /home/ezio/.julia/dev/AuthApp/app/resources/authentication/views/register.jl.html
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/authentication/views/success.jl.html to /home/ezio/.julia/dev/AuthApp/app/resources/authentication/views/success.jl.html
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/app/resources/users
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/users/Users.jl to /home/ezio/.julia/dev/AuthApp/app/resources/users/Users.jl
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/app/resources/users/UsersValidator.jl to /home/ezio/.julia/dev/AuthApp/app/resources/users/UsersValidator.jl
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/db
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/db/migrations
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/db/migrations/2019052410085235_create_table_users.jl to /home/ezio/.julia/dev/AuthApp/db/migrations/2019052410085235_create_table_users.jl
[ Info: 2022-08-02 09:50:01 Created dir /home/ezio/.julia/dev/AuthApp/plugins
[ Info: 2022-08-02 09:50:01 Copied /home/ezio/.julia/packages/GenieAuthentication/4CYFn/files/plugins/genie_authentication.jl to /home/ezio/.julia/dev/AuthApp/plugins/genie_authentication.jl

julia> SearchLight.Migration.up("CreateTableUsers")
[ Info: 2022-08-02 09:50:56 SELECT version FROM schema_migrations ORDER BY version DESC
[ Info: 2022-08-02 09:50:56 CREATE TABLE users (id INTEGER PRIMARY KEY , username TEXT  , password TEXT  , name TEXT  , email TEXT  )
[ Info: 2022-08-02 09:50:56 CREATE  INDEX users__idx_username ON users (username)
[ Info: 2022-08-02 09:50:56 INSERT INTO schema_migrations VALUES ('2019052410085235')
[ Info: 2022-08-02 09:50:56 Executed migration CreateTableUsers up

julia> Genie.Generator.newcontroller("Admin", pluralize = false)
ERROR: ArgumentError: Package AuthApp does not have ViewHelper in its dependencies:
- If you have AuthApp checked out for development and have
  added ViewHelper as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with AuthApp
Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:980
 [2] top-level scope
   @ ~/.julia/dev/AuthApp/app/resources/authentication/AuthenticationController.jl:6
in expression starting at /home/ezio/.julia/dev/AuthApp/app/resources/authentication/AuthenticationController.jl:6
ERROR: ArgumentError: Package AuthApp does not have UsersValidator in its dependencies:
- If you have AuthApp checked out for development and have
  added UsersValidator as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with AuthApp
Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:980
 [2] top-level scope
   @ ~/.julia/dev/AuthApp/app/resources/users/Users.jl:3
in expression starting at /home/ezio/.julia/dev/AuthApp/app/resources/users/Users.jl:3
ERROR: ArgumentError: Package AuthApp does not have ViewHelper in its dependencies:
- If you have AuthApp checked out for development and have
  added ViewHelper as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with AuthApp
Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:980
 [2] top-level scope
   @ ~/.julia/dev/AuthApp/app/resources/authentication/AuthenticationController.jl:6
in expression starting at /home/ezio/.julia/dev/AuthApp/app/resources/authentication/AuthenticationController.jl:6
[ Info: 2022-08-02 09:51:02 New controller created at /home/ezio/.julia/dev/AuthApp/app/resources/admin/AdminController.jl

julia> include(joinpath("plugins", "genie_authentication.jl"))
ERROR: LoadError: ArgumentError: Package AuthenticationController not found in current path:
- Run `import Pkg; Pkg.add("AuthenticationController")` to install the AuthenticationController package.

Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:967
 [2] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [3] top-level scope
   @ REPL[12]:1
in expression starting at /home/ezio/.julia/dev/AuthApp/plugins/genie_authentication.jl:3

cc : @essenciary

essenciary commented 1 year ago

I think it needs a few more fixes to support Genie 5 - I'll take a look

Wikunia commented 1 year ago

I've tried some more:


The resulting repo can be found here: https://github.com/Wikunia/AuthApp.jl
Wikunia commented 1 year ago

With this commit: https://github.com/Wikunia/AuthApp.jl/commit/73da067fd601bbe34d1e778ae0d7af6d69ecd46c I was able to redirect myself to the show login page, login and check that I'm actually logged in. Though I'm still getting the ERROR: UndefVarError: Users not defined error when starting with bin/repl

essenciary commented 1 year ago

All the issues should now be solved in v2.1.1