CodeIgniter Forums
How to add users in Myth/Auth in batches - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: How to add users in Myth/Auth in batches (/showthread.php?tid=81823)



How to add users in Myth/Auth in batches - yoshi - 05-02-2022

Thanks for everything.
I was able to add login functionality to an existing app using Myth/Auth, but the next step is to add a large number of dummy users for development. For example, creating a school management system, a school teacher and a school student (e.g. [email protected]).

On the db, if I copy password_hash, activate_hash, active to the users I added with seeder, they can't seem to log in (great in production!). .

Is there any way to add each user in bulk (dummy users can log in) with seeder or other software for development?

Alternatively, it might be possible to add a non-activated user in seeder and add a record to the school_users table using only the id as a foreign key.


RE: How to add users in Myth/Auth in batches and how to input user names in Japanese - JustJohnQ - 05-02-2022

I use the site below to generate dummy data:
http://filldb.info/


RE: How to add users in Myth/Auth in batches and how to input user names in Japanese - yoshi - 05-03-2022

(05-02-2022, 11:29 PM)JustJohnQ Wrote: I use the site below to generate dummy data:
http://filldb.info/

thanks, JustJohnQI. Smile
I'm not having trouble creating dummy data itself, I just don't know how to approve dummy users in batches.


RE: How to add users in Myth/Auth in batches and how to input user names in Japanese - InsiteFX - 05-03-2022

Why not use the Database Seeder to add the data to the database table?


RE: How to add users in Myth/Auth in batches and how to input user names in Japanese - yoshi - 05-03-2022

(05-03-2022, 12:53 AM)InsiteFX Wrote: Why not use the Database Seeder to add the data to the database table?

thanks InsiteFXWhy.

Yes, I am. I am using a database seeder to create users.

I have just noticed the 1st question's answer.
I discovered that the following two dummy users have different passwords.
Instead of using a converted value for each user, using a single converted value.

The password_hash function was converting the same words but spitting out different hashes. This was the cause.

PHP Code:
[
    'id' => 1,
    'email' => '[email protected]',
    'username' => 'sample teacher1',
    'activate_hash' => '59481d0b64af5c49a971bee3ea104ba9',
    'password_hash' => password_hash('apple1111'PASSWORD_DEFAULT),  <-- A
    
'active' => 1,
],
[
    'id' => 2,
    'email' => '[email protected]',
    'username' => 'sample teacher2',
    'activate_hash' => '579257a205f0b1c4947f01d4979afdf4',
    'password_hash' => password_hash('apple1111'PASSWORD_DEFAULT),  <-- B
    
'active' => 1,
], 



RE: How to add users in Myth/Auth in batches - kenjis - 05-03-2022

What's your problem?
Myth:Auth has administration commands:
https://github.com/lonnieezell/myth-auth/blob/develop/src/Commands/CreateUser.php
https://github.com/lonnieezell/myth-auth/blob/develop/src/Commands/ActivateUser.php
You can see how to do in them.


RE: How to add users in Myth/Auth in batches - yoshi - 05-03-2022

(05-03-2022, 05:17 AM)kenjis Wrote: What's your problem?
Myth:Auth has administration commands:
https://github.com/lonnieezell/myth-auth/blob/develop/src/Commands/CreateUser.php
https://github.com/lonnieezell/myth-auth/blob/develop/src/Commands/ActivateUser.php
You can see how to do in them.

thanks, kenjis

My problem was to copy a dummy user for testing the aggregation process. At first I thought that copying dummy users would not work because I did not know how to use Myth/Auth, but what I found out was that "the exact same word will produce different results when hashing is applied.

This problem was solved by putting the value after hashing into a variable and using it around.