This topic is locked
[SOLVED]

 Add new user programmatically?

12/13/2020 5:53:41 PM
PHPRunner General questions
A
AlphaBase author

I don't see a method to do this. Basically I don't want to make a client an "Admin" will full access to permission settings. He just needs to be able to add users and assign them to a group(s). The group part is simple. But adding a user means knowing the encryption method. Is there a way?

lefty 12/13/2020

The below link / post may help! With Dynamic Permissions. It worked for me without giving full access , only access to setup users and assign them to a group but not admin by structuring the query in the view to not include admin group from uggroups table. You would or the person setting up the user would have to send them a password reset / reminder for them to change password for access or they can on their own once they are setup.
Sub Admin

A
AlphaBase author 12/13/2020

Thanks for you response and for the link, John.

But for me, the question is: how do I assign a new user with a passwordas a "sub-admin".

lefty 12/14/2020



Thanks for you response and for the link, John.

But for me, the question is: how do I assign a new user with a passwordas a "sub-admin".


Add a group for example called SubAdmin. Then setup the permissions for them for your custom view and other pages you may need them to access. Send the sub-admin a password / reset from the login page. Now they will have only access to your custom view of the users table , where you can leave out the password field and make uugroups the details so the sub-admin can also edit a user and change from one group to another.

A
acpan 12/14/2020

This is what worked for me, if you are using BYCRYPT encryption in your PHPR project and want to programmatically add users, you can try to encrypt the plain password to encrypted password with PHP's function password_hash:
$password_encypted = password_hash($password_plain_text, PASSWORD_DEFAULT);
Where password_hash is a PHP Function, and $password_plain_text is the plain password user enters or you assign.
With that you can update or insert the encrypted password to the user table.
Note: More info about PHP's password_hash function at PHP password_hash function



Thanks for you response and for the link, John.

But for me, the question is: how do I assign a new user with a passwordas a "sub-admin".

A
AlphaBase author 12/14/2020



$password_encypted = password_hash($password_plain_text, PASSWORD_DEFAULT);



Perfect!

Thank you acpan. That's what I was looking for.

Thanks again, John, for your suggestions.