lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
632 stars 206 forks source link

CLI command to create_user fails - password_hash is required #180

Closed JamesShaver closed 4 years ago

JamesShaver commented 4 years ago

It looks like the CLI method to create a user doesn't work, as the password_hash field is required. Here's a copy/paste of what I'm seeing:

[centos@hostCodeIgniter4]$ php spark auth:create_user

CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-04-06 17:21:46pm

Username: admin
Email: myemail@myhost.com
The password_hash field is required.
JamesShaver commented 4 years ago

My apologies if I'm doing this wrong (new to github), but I made a pull request to update the CreateUser file. Let me know any issues... https://github.com/lonnieezell/myth-auth/pull/181

michalsn commented 4 years ago

I couldn't recreate this in the latest dev branch.

php spark auth:create_user

CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-04-07 09:15:47am

Username: test
Email: test@test.com
New user created: test, #2
JamesShaver commented 4 years ago

Can you tell me what's happening with the password field in your scenario? Since the field is required, how is the password being generated? password_hash varchar(255) NOT NULL,

JamesShaver commented 4 years ago

I just ran through a fresh install, following these steps below... same issue. I'm not discounting that this may be my fault in some way, but I don't see it yet. Please let me know if I'm missing something.

d:\xampp\htdocs>composer create-project codeigniter4/appstarter CI4 -s rc d:\xampp\htdocs>cd CI4 d:\xampp\htdocs\CI4>composer config minimum-stability dev d:\xampp\htdocs\CI4>composer require myth/auth CI4\app\Config\App.php - public $baseURL = 'http://localhost/CI4/public/'; CI4\app\Config\Database.php - updated d:\xampp\htdocs\CI4>php spark migrate -all CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-04-07 09:01:52am

Running all new migrations... Running: (Tests\Support) 20160428212500_Tests\Support\Database\Migrations\Migration_Create_test_tables Running: (Myth\Auth) 2017-11-20-223112_Myth\Auth\Database\Migrations\CreateAuthTables Running: (Tests\Support) 2020-02-22-222222_Tests\Support\Database\Migrations\ExampleMigration Done

d:\xampp\htdocs\CI4>php spark auth:publish

CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-04-07 09:03:31am

Publish Migration? [y, n]: y created: Database/Migrations/2017-11-20-223112_create_auth_tables.php Remember to run spark migrate -all to migrate the database. Publish Models? [y, n]: y created: Models/LoginModel.php created: Models/UserModel.php Publish Entities? [y, n]: y created: Entities/User.php Publish Controller? [y, n]: y created: Controllers/AuthController.php Publish Views? [y, n]: y created: Views/Auth/emails\activation.php created: Views/Auth/emails\forgot.php created: Views/Auth/forgot.php created: Views/Auth/layout.php created: Views/Auth/login.php created: Views/Auth/register.php created: Views/Auth/reset.php created: Views/Auth/_footer.php created: Views/Auth/_header.php created: Views/Auth/_message_block.php created: Views/Auth/_navbar.php Publish Config file? [y, n]: y created: Config/Auth.php Publish Language file? [y, n]: y created: Language/en/Auth.php

d:\xampp\htdocs\CI4>php spark auth:create_user

CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-04-07 09:03:53am

Username: admin Email: myemail@myhost.com The password_hash field is required.

michalsn commented 4 years ago

As I said, please use the latest dev version. In your composer.json file:

"myth/auth": "dev-develop"

I also strongly advise you not to use:

"minimum-stability": "dev"

...unless you're just checking out the project.

JamesShaver commented 4 years ago

Well it's interesting to me that this worked... I'm new to composer/github, and I had assumed this would install the latest: composer require myth/auth I initially wasn't able to install auth without setting the minimum stability. I updated composer.json as you mentioned, removed the minimum stability, and used composer update to install.

Thanks for your help