Welcome Guest, Not a member yet? Register   Sign In
SHIELD: disable autonomous user registration
#1
Information 
(This post was last modified: 01-20-2024, 04:33 AM by Corsari.)

Hello
I'm experimenting with SHIELD because my need is to make a totally private app on a public hosting

Because of that, I'd like to make the registration process fully private too, more precisely I'd like that me as administrator, will be the unique one that is enabled to register users from "the admin side"

Later the whole app (from root to bottom) will be protected by SHIELD authentication while publicly it will be seen only the login page but trimmed to just user name and password fields

They come to my mind few manners for achieving that

though I thank you so much if some SHIELD expert can point out the correct approach and methods to do achieve that , at least the part to correctly disable the users self registration

Thank you





Hello
found one setting in
\app\Config\Auth.php


PHP Code:
    /**
    * --------------------------------------------------------------------
    * Allow Registration
    * --------------------------------------------------------------------
    * Determines whether users can register for the site.
    */
    public bool $allowRegistration false


which is the case

Now it does remain the case of an administrator users registration section:
should be written from scratch? Or it can be done something making use of the SHIELD controllers and views?

Thank you



About an Admin Users creation/registration controller and view

Looks like the it should be used this part of the guide
https://shield.codeigniter.com/user_mana...ting-users

(well looks like that writing on the forum, allows me to find the right addresses on the guide)
Blush
Reply
#2

This is what I use to create the SuperAdmin Account, it depends on what the default user group is set to in
app/Config/AuthGroups.php

PHP Code:
/**
 * createUser ()
 * -------------------------------------------------------------------
 *
 * @param string $userName
 * @param string $emailAddress
 * @param string $password
 */
public function createUser(string $userName ''string $emailAddress ''string $password ''): void
{
    // Get the User Provider (UserModel by default)
    $users auth()->getProvider();

    // Users record
    $user = new User([
        'username' => $userName,
        'email'    => $emailAddress,
        'password' => $password,
    ]);

    // Save the new user information
    $users->save($user);

    // To get the complete user object with ID, we need to get from the database
    $user $users->findById($users->getInsertID());

    // Add to default group
    $users->addToDefaultGroup($user);

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(01-21-2024, 10:35 AM)InsiteFX Wrote: This is what I use to create the SuperAdmin Account, it depends on what the default user group is set to in
app/Config/AuthGroups.php

PHP Code:
/**
 * createUser ()
 * -------------------------------------------------------------------
....
    $users->addToDefaultGroup($user);


thank you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB