Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Basic Authentication with simpleauth
  • I'm just getting started with FuelPHP and MVC frameworks in general. I took some notes while trying to get the authentication (Auth w/ SimpleAuth driver) to work....maybe they'll help someone out. The notes can be found here: http://saaboke.com/?p=177
    The code is on github: https://github.com/jsidhu/FuelPHP-Auth-Example -js
  • Does anyone have a copy of the notes still? I can access the files on github, but the link to the notes (http://saaboke.com/?p=177) no longer works.. Any help would be appreciated!
  • website has been restored. FuelPHP's undergone quite a number of changes since I took those notes, I'll update my notes.. -js
  • Just a heads up to those interested: I've updated my notes to work with the current 1.0 rc2.1 release. http://saaboke.com/?p=236
    https://github.com/jsidhu/FuelPHP-Auth The Readme.md includes the raw html file that includes all of my notes for this project.
  • Very nice job on the tutorial! There's some good examples of a bit of everything on it, which I believe is the only thing the documentation lacks. :)
  • Step 9: Edit app/config/simpleauth.php and change the tablename to 'users'

    Tablename? There is just an array of groups and roles.. no tablename.
    return array(
     'groups' => array(
      -1 => array('name' => 'Banned', 'roles' => array('banned')),
      0 => array('name' => 'Guests', 'roles' => array()),
      1 => array('name' => 'Users', 'roles' => array('user')),
      50 => array('name' => 'Moderators', 'roles' => array('user', 'moderator')),
      100 => array('name' => 'Administrators', 'roles' => array('user', 'moderator', 'admin')),
     ),
    
     'roles' => array(
      '#' => array('website' => 'r'), // default rights
      'banned' => false,
      'user' => array('comments' => 'cr'),
      'moderator' => array('comments' => 'ud'),
      'admin' => array('website' => 'cud', 'admin' => 'crud'),
      'super' => true,
     ),
    );
    
  • Hey, are you running beta? the table name exists in develop branch
  • Well written article man, and I do agree that we could use some more basic examples in the user guide! Right now what I'm missing the most is some proper examples on advanced relationships with the activerecord package. I have some questions though, I see you're extending the auth drivers and placed it in app/classes. Why? I see you're also doing
    if (count($uri_string)>1 and $uri_string[0] == 'users' and ($uri_string[1] == 'login' or $uri_string[1] == 'signup'))
    

    Shouldn't you be using the Request class instead of accessing the uri directly?
  • drifitz drifitz wrote on 02/27/11 2:20 am:
    ...
    I have some questions though, I see you're extending the auth drivers and placed it in app/classes. Why?

    I'm still getting used to git. I actually kept working in this example and "pulled" out the simpleauth from the /core/classes and put them into /app/classes because thats the place our customized code needs to live. I think the next step for me would be to work on a more customized authentication system. Such as using email as the username, collecting other data, email activation etc. So, if you check my github repo, there are three branches. You probably got "master". The other two repo's are simpleauth and complexauth. What you saw in master was the branch "complexauth"...which is not really complex, its the same as simpleauth, but separated out into the /app/classes so we can start modifying our own version of simpleauth.
    drifitz drifitz wrote on 02/27/11 2:20 am:
    I see you're also doing
    if (count($uri_string)>1 and $uri_string[0] == 'users' and ($uri_string[1] == 'login' or $uri_string[1] == 'signup'))
    

    Shouldn't you be using the Request class instead of accessing the uri directly?

    You are correct. This code is from the stationwagon example, the correct way to do this would be:
    if($this->request->controller == 'users' && ($this->request->action == 'login' or $this->request->action == 'signup'))
    
  • Ok, that explains a lot ;). Thanks. I see lot's of changes.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion