Part of the EllisLab Network
   
16 of 36
16
FreakAuth_light authentication library/admin application released!
Posted: 23 February 2007 06:58 PM   [ Ignore ]   [ # 226 ]  
Summer Student
Avatar
Total Posts:  23
Joined  10-09-2006

hey Dan,

Found a small bug.

if ($_username != false AND $_role != false AND $_role=='user')

in the library (row 250) should be

if ($_username != false AND $_role != false)

because if I create an custom roll, I’m also a valide user.

 Signature 

<? echo $_GET[‘a_life’]; ?>

Profile
 
 
Posted: 24 February 2007 12:44 PM   [ Ignore ]   [ # 227 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  493
Joined  02-21-2007

Thanks wolfear for this good suggestions, just two things to say.

The first :

wolfear - 22 February 2007 06:35 PM

————————————————————-
In template_admin -> add.php

Incorrect nesting of elements
Change all:

<p><label

to

<div><label

Change Lines 19, 40, 49,  58, 67, 77, 92
sample:

<span><?=(isset($this->validation) ? $this->validation->{$field.'_error'} : '')?></span></p>

should be:

<?=(isset($this->validation) ? $this->validation->{$field.'_error'} : '')?></div>

this nesting is correct for me

I just found a bad id=”“, we could replace

<p><label for="country_id">is banned?</label>
<?=form_checkbox('banned', 1, FALSE)?>

with

<p><label for="banned">is banned?</label>
<?=form_checkbox(array('name'=>'banned','id'=>'banned','value'=>'1','checked'=>FALSE))?>

The last thing :

——————————————————————————-
In template_admin -> list.php
Duplicate “submit” -> I just removed the top form.

I think that this second “add user” button is convenient,
we could just rename the second id=“submit2”

Also, in this file, I found a small typo :

<p><label for="password">passoword:</label>
Profile
 
 
Posted: 24 February 2007 05:46 PM   [ Ignore ]   [ # 228 ]  
Summer Student
Avatar
Total Posts:  9
Joined  02-07-2007

grahack-
There is not really a “functional” problem, but it is a problem if we want valid code.
I changed those because this:

<span><?=(isset($this->validation) ? $this->validation->{$field.'_error'} : '')?></span></p>

Produces a div, inside of a span, inside of a paragraph, when combined with the label.
You end up with paragraph block-> inline span-> division block.

One cannot “legally” have a block element contained inside of an inline element if you want to be valid (CSS level 2 specs).

The proper nesting would be division block-> paragraph block-> inline span.

By replacing the the paragraph element with a div, we keep the block level hierarchy correct since it is permissible to nest divs.

————————
True, the duplicate submits are convenient, especially if you have a large number of entries.
The current code just produces a duplicate ID error.  Your idea to rename would work fine also. I just took the easy way out.
I should have stated that there were other options. My bad.

 Signature 

Good judgment comes from experience, most of which comes from bad judgment.

chown /usr/beer
unmount /dev/brain

Profile
 
 
Posted: 25 February 2007 08:10 AM   [ Ignore ]   [ # 229 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  514
Joined  12-05-2006
jaapio - 23 February 2007 06:58 PM

hey Dan,

Found a small bug.

if ($_username != false AND $_role != false AND $_role=='user')

in the library (row 250) should be

if ($_username != false AND $_role != false)

because if I create an custom roll, I’m also a valide user.

Hey Jaapio this is not a bug.
User is one of the 3 default roles in FreakAuth_light along with admin and superadmin.
The method you refer to isValidUser() returns TRUE if the logged-in person has a role of user

There are other 3 methods to check for different roles:
- isAdmin()
- isSuperAdmin()
- belongsToGroup()

All this methods are described in detail in the DOCUMENTATION

The user_temp table in DB has the purpose of storing registered but not yet activated people that subscribed to the website. Once they activate their account they get moved from the user_temp table to the user table.

To Jaapio and all the gang of FreakAuth_light users:
if you are not sure about some code, please ask WHY some code has been written before reporting it as a bug.
One thing is to report possible customisations, another is to report bugs.

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 25 February 2007 09:43 PM   [ Ignore ]   [ # 230 ]  
Summer Student
Avatar
Total Posts:  9
Joined  02-20-2007

Danfreak: Bloody fantastic system you have made here. I love it.
To the rest of the community: Great work guys. It is good to see so much support for this application, and the CI framework in general.

Thanks Steve. This fix really helped me.

stevepaperjam - 19 February 2007 09:10 AM

Thanks to Dan for getting this updated version out so quickly.

I was going to post this in a separate thread, but it shouldn’t take long: any PHP4 users had a go with a new version yet?

I had a problem when opening the view user (or admins) page, which the log file tracked down to line 1139 in libraries/Freakauth_light.php

$db_fields =$this->CI->userprofile->getTableFields();

In discussion with Dan last night, I thought it might be my set-up (PHP4.4.0, Apache 2.something).

I’ve just had a bit more of a fiddle with it, and moving the loading of the model (just above that line) to the constructor seems to fix the issue.

This change also still works in PHP5.0.4 as well. (I’m using MAMP to flip between PHP versions, by the way…)

I had two postgres related issues with using FreakAuth and have come up with a solution for both. Hope these help any postgres users out there. These fixes are probably only relevant for people using v7.x of postgres.

Bug 1
Not sure if this is caused by postgres or by my verison of php 4, but when trying to add a new user it would constantly try to add the user with an id = 0 seeing as that is what the ‘add user’ form uses to denote a new user.
My fix was to remove the id=0 from the array just before it gets passed to the insert function. That way the SERIAL id field will automatically get a new id for this user record.

$values=$this->_get_form_values();
            
/* Fix for the Add new user routine.
            *  in php4 and postgres < 8 sending this is setting
            *  id = 0 for all new records.
            *  If the id key is removed completely a new ID will be generated.
            *  - Gerard
            * */
            
if($values['user']['id'] == 0){
                
unset($values['user']['id']);
            
}
//insert data in DB
$this->usermodel->insertUser($values['user']);

Bug 2
I discovered that for a postgres database 7.x the insert_id() function doesn’t work as it is being used in the adding of profiles when a user is being created.  The only way for 7.x to tell what the previous id of an insert is, is to check the sequence responsible for the SERIAL id value. The CI Postgres driver already allows for this, but a slight modification needs to be made to freakauth to take advantage of this 7.x way of doing things. To do this, I had to change the code in the application/controllers/admin/auth.php file as follows:

if($this->config->item('FAL_create_user_profile'))
            
{    
                  
//let's get the last insert id
                  //FIX -  add fa_user_id_seq in the line below
                  
$values['user_profile']['id']= $this->db->insert_id('fa_user_id_seq');
                
}

Also, if anyone wants it, I wrote a converted PostgreSQL script for installing the base tables for FreakAuth.

Please let me know if there is a way of fixing the above bugs better than I have done.

Cheers,

Gerard

Profile
 
 
Posted: 26 February 2007 08:07 AM   [ Ignore ]   [ # 231 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  02-06-2007

there’s something I’m trying to do with the menus that i didn’t get it yet in CI
how can i make links only available for a group use?

i know that i need to do a if condition to see if the user is logged in and there’s info at the session
if he is logged in show links if not show other links…i’m doing this and its not working :(

Profile
 
 
Posted: 26 February 2007 08:16 AM   [ Ignore ]   [ # 232 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  514
Joined  12-05-2006

Let’s say you want to display a menu item only to members of users (belonging to group users) if they are logged in.

EXAMPLE (views/FreakAuth_light/menu.php)

<div id="navlist">
        <
ul id="navlist">
            <
li id="active"><?=anchor('', 'home')?></li>
            <
li><?=anchor('auth/', 'login')?></li>
            <
li><?=anchor('auth/register', 'register')?></li>
            <
li><?=anchor('auth/forgotten_password', 'forgotten password')?></li>
            <
li><?=anchor('auth/changepassword', 'change password')?></li>
            <
li><?=anchor('admin/', 'admin')?></li>
            
<?php
            
//display this only to logged in users
            
if (isValidUser())
            
{?>
            
<li><?=anchor('myprofile/'.$this->db_session->userdata('id'), 'myprofile')?></li>
            
<?php
            }
            ?>
        
</ul>
    </
div>

To use this example you need:
- a myprofile.php controller
- to set this in your config/routes.php

$route['myprofile/:num'] = "myprofile";

Check the method belongsToGroup($group=null, $only=null) if you want to display something to members of your custom groups beside users.

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 26 February 2007 08:20 AM   [ Ignore ]   [ # 233 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  02-06-2007

that’s what i’m doing and its not showing anything, gonna recode it again wink

and for the login, register, etc links?if a user logs in we want that those links go away how can i do that?

Profile
 
 
Posted: 26 February 2007 08:25 AM   [ Ignore ]   [ # 234 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  514
Joined  12-05-2006
<div id="navlist">
        <
ul id="navlist">
            <
li id="active"><?=anchor('', 'home')?></li>
            
<?php
            
//display this only to NOT logged in users
            
if (belongsToGroup()==FALSE)
            
{?>
            
<li><?=anchor('auth/', 'login')?></li>
            <
li><?=anchor('auth/register', 'register')?></li>
            <
li><?=anchor('auth/forgotten_password', 'forgotten password')?></li>
            <
li><?=anchor('auth/changepassword', 'change password')?></li>
            <
li><?=anchor('admin/', 'admin')?></li>
            
<?php
            }
            
//display this only to logged in users
            
if (isValidUser()==TRUE)
            
{?>
            
<li><?=anchor('myprofile/'.$this->db_session->userdata('id'), 'myprofile')?></li>
            
<?php
            }
            ?>
        
</ul>
    </
div>
 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 26 February 2007 08:31 AM   [ Ignore ]   [ # 235 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  02-06-2007

i was thinking to use the sessions, where session->userdata(logged_in) if this was true it would hide those links,
but that way u gave its easier wink thanx

Edit: isn’t guests a group to?so that would hide links from guests too,or I’m wrong?

Profile
 
 
Posted: 26 February 2007 09:06 AM   [ Ignore ]   [ # 236 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  514
Joined  12-05-2006
wemago - 26 February 2007 08:31 AM

isn’t guests a group to?so that would hide links from guests too,or I’m wrong?

In a certain way it is a group.

All people not logged in belong to the group guest.

Because this group works in a kinda “negative” fashion, it doesn’t need to be defined in your application/config/freakauth_light.php

//----------------------------------------------------
// ROLES SETTINGS (don't change them)
//----------------------------------------------------
//roles work by inheritance
//this means that the lower the value of the role, the higher in the hierarchy
//i.e superadmin (value 1) has more rights than admin (value 2)
//i.e editor (value 3) has more rights than user (value 100)
//
//you can also set usergroups with the same hierarchy
//i.e.
//'editor' => 4,
//'gallery_manager' => 4
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WARNING do not set custom groups with value 1 or 2
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$config['FAL_roles'] = array(
                            
//don't change the two following lines//
                             
'superadmin' => 1,
                             
'admin' => 2,
                             
//end don't change
                             
                             //add your custom roles here
                             //'editor' => 3,
                             //'gallery_manager' => 4
                             //--------------------------
                             
                             //don't change the following line
                             
'user' => 100,
                            );
 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 26 February 2007 01:10 PM   [ Ignore ]   [ # 237 ]  
Summer Student
Total Posts:  15
Joined  10-20-2006

I’m looking for an auth library that can do the following things:

- has an API, nothing else! So no styles, no views, nothing. Works only through a library. Most libraries here are written as if the end user can’t code a single line…
- has ACL, or at least some roles
- is independent of the session library (native, db, ...)
- can be scaled if necessary, so it should be possible to disable ACL etc for simpler auth.

- Freakauth seems to get close, but is there a way to strip it ??

Anybody?
Thanks !

Profile
 
 
Posted: 26 February 2007 05:33 PM   [ Ignore ]   [ # 238 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  277
Joined  02-07-2007

I have stripped FAL for use in my own application successfully - and it works quite well.

Profile
 
 
Posted: 26 February 2007 06:20 PM   [ Ignore ]   [ # 239 ]  
Research Assistant
RankRankRank
Total Posts:  303
Joined  10-17-2006
Iksander - 26 February 2007 05:33 PM

I have stripped FAL for use in my own application successfully - and it works quite well.

You mind sharing it with the rest of us?

Profile
 
 
Posted: 26 February 2007 10:05 PM   [ Ignore ]   [ # 240 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  277
Joined  02-07-2007

Sure - if you use a similar view embedding pattern that Rick gave an example of - you should be able to simple change the ‘container’ that the auth.php file calls for _login, register, etc… to your own sites container view and load the individual content page which is completely seperate from the body of FAL’s container views - and then simply give the content view its own pseudo classes or id’s.

The only thing is - it takes some time to sift through the code and insert your own stuff…

If you want my code examples, I can give them -  I just figured giving a basic description would be quicker for you than not, is it isn’t the case - tell me so and I will upload my own examples…

Profile
 
 
   
16 of 36
16
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 77568 Total Logged-in Users: 13
Total Topics: 101557 Total Anonymous Users: 3
Total Replies: 544401 Total Guests: 203
Total Posts: 645958    
Members ( View Memberlist )
Newest Members:  ColeJLinskitnealsemperjrawhallshiusbozzlynobluffkatiejameshsmith101dddougal
Active Members:    BorisKbtray77CrucialdenbadHerbkusmayadinetrosisPascal KrietepascalnRD Gambolaskeletonfriendspider pigtheQco