Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Creating an admin #2

Open
michaelsomerville opened this issue Jun 16, 2016 · 6 comments
Open

Creating an admin #2

michaelsomerville opened this issue Jun 16, 2016 · 6 comments

Comments

@michaelsomerville
Copy link

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

@michaelsomerville
Copy link
Author

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 ?

@Repox
Copy link
Owner

Repox commented Jun 18, 2016

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;
    }

@michaelsomerville
Copy link
Author

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

@michaelsomerville
Copy link
Author

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

@Repox
Copy link
Owner

Repox commented Jun 24, 2016

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

@michaelsomerville
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants