SimpleUsers icon indicating copy to clipboard operation
SimpleUsers copied to clipboard

Creating an admin

Open michaelsomerville opened this issue 8 years ago • 6 comments

Hey, Great starter script here! I am wondering how to identify a user as "Admin" ?

michaelsomerville avatar Jun 16 '16 22:06 michaelsomerville

In addition - how do we configure a forgot password with this script ?

I am also, attempting to create a "sign as user" - have you had luck with this ?

michaelsomerville avatar Jun 17 '16 20:06 michaelsomerville

Hi.

Hey, Great starter script here! I am wondering how to identify a user as "Admin" ?

There is no "admin" user, but you could grant a user an attribute identifying them as an admin:

$simpleusers->setInfo('admin', 1);

And to test it:

if($simpleusers->getInfo('admin'))
{
    // is admin
}

In addition - how do we configure a forgot password with this script ?

You would have to manually create a process to this and then use the method setPassword. The script doesn't help you with all the mails and tokens necessary to do this in a secure way.

I am also, attempting to create a "sign as user" - have you had luck with this ?

Well, it wouldn't be hard to make, by adding a new method to the script:

    public function loginAs($userId)
    {
        if($user = $this->getSingleUser($userId))
        {
            $_SESSION[$this->sessionName]["userId"] = $user["userId"];
            $this->logged_in = true;

            return true;
        }

        return false;
    }

Repox avatar Jun 18 '16 18:06 Repox

Awesome! Thanks for the support and comments, much appreciated on that.

michaelsomerville avatar Jun 23 '16 17:06 michaelsomerville

Quickly, would that sign as user ... dump a url ? Sorry, I am not an advanced coder. Lol

michaelsomerville avatar Jun 23 '16 17:06 michaelsomerville

No, you would have to create a route to a URL yourself, where you use that specific method.

Repox avatar Jun 24 '16 06:06 Repox

Okay, I am extremely lost with that function - where would I push that into the code ? and how would I call it.

michaelsomerville avatar Jun 30 '16 23:06 michaelsomerville