Part of the EllisLab Network
   
 
FreakAuth_light 1.1 bug?
Posted: 27 May 2008 04:19 AM   [ Ignore ]  
Summer Student
Total Posts:  2
Joined  05-27-2008

Hi

Having installed FreakAuth_light 1.1 and enabled user profiles, I have a problem! As admin, if I edit a record, when I hit “Save” I get a database error. The precise error is:

A Database Error Occurred

Error Number
1064

You have an error in your SQL syntax
check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

SELECT 
FROM (`fa_user`) WHERE `id` = 

From my digging, this seems to be coming from application/controllers/admin/users.php and in particular the first line of function edit($id = ‘’) which says:

function edit($id '')
    
{

        
// security check:
        // admins or superadmins cannot be edited in the users controller
        
$edited_role getUserPropertyFromId($id'role');
        
$allowed = ($edited_role != 'admin' AND $edited_role != 'superadmin');
        if (!
$allowed$this->freakauth_light->denyAccess(getUserProperty('role')); 

The problem seems to be that the $id is not getting passed to the function by the edit form (and is being explicitly blanked by the function declaration), resulting in the security check failing - getUserPropertyFromId causes the database error as the WHERE clause in the query has nothing for $id.

Tracking this back, I’ve found application/views/FreakAuth_light/template_admin/users/edit.php and in particular the form open statement:

<?=form_open('admin/users/edit/')?> 

By changing this to:

<?=form_open('admin/users/edit/' . (isset($user['id']) ? $user['id'$this->fal_validation->{'id'}))?> 

I can make the problem go away (i.e. I can edit users), but I’m a bit concerned that (a) this seems like a big problem that surely somebody would have seen before if it was “real”, and (b) am I opening up other problems later?

Apart from that, great work, well done and thank you!

Profile
 
 
Posted: 27 May 2008 05:15 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  164
Joined  04-26-2008

SELECT * FROM (`fa_user`) WHERE `id` =


try to change the above code with

SELECT * FROM `fa_user` WHERE `id` =

Profile
 
 
Posted: 27 May 2008 06:08 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  84
Joined  05-15-2008

I had the same error on three separate installs on different servers and I thought I was crazy. Thanks for the fix!

 Signature 

Blog | Work | Freelance

Profile
 
 
Posted: 04 June 2008 09:22 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  1
Joined  06-04-2008

Hi there. I have the same problem, but after applying your part of code, when I’m trying to edit an admin a error message pops up: ‘You do not have the credentials to access this reserved area.’. And I am logged as a superadmin, so i guess something’s still wrong..
Best wishes, wteq

Profile
 
 
Posted: 11 June 2008 03:38 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  1
Joined  06-11-2008
wteq - 04 June 2008 01:22 PM

Hi there. I have the same problem, but after applying your part of code, when I’m trying to edit an admin a error message pops up: ‘You do not have the credentials to access this reserved area.’. And I am logged as a superadmin, so i guess something’s still wrong..
Best wishes, wteq

Hi,
try to change this line (controllers/admin/users.php line 345):

$allowed = ($edited_role != 'admin' AND $edited_role != 'superadmin'); 

to

$allowed = ($edited_role != 'admin' OR $edited_role != 'superadmin'); 

I hope this helps, it worked for me.

Profile
 
 
Posted: 19 June 2008 05:26 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-30-2006
Gewa - 27 May 2008 09:15 AM

SELECT * FROM (`fa_user`) WHERE `id` =

try to change the above code with

SELECT * FROM `fa_user` WHERE `id` =

Where would this edit be made?

Profile
 
 
Posted: 22 June 2008 04:44 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  297
Joined  02-21-2007

@ skwdenyer
Thanks for fixing this. a) It’s a real bug I think I’ve faced once. b) Future will tell, but I guess no.

@ Gewa & Chris Williams
This query is made with Active Record, you won’t be able to change the sql without touching the db driver. Anyway to me the problem is related to the emptyness after ‘=’.

@ wteq & akidur
You shouldn’t access admins edition through the admin/users controller. That’s why I think you accessed the form tweaking the url. Did you?

Profile
 
 
Posted: 12 July 2008 02:20 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  225
Joined  06-04-2007

Thanks for fix smile

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 16 July 2008 04:18 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  06-05-2007

I had the same exact problem as skwdenyer. Now when I finished the required fixes a whole can of worms have opened up. Errors such as I can’t edit Admins as a Super Admin. Grahack you mentioned that we should not access admins edition through the admin/users controller. I agree but what fix do you propose?

 Signature 

Functional PHP Extension A set of higher-order functions and other primatives written in PHP (3/4 compatible) which let you write php code in a functional style, similar to the way you might in Haskell, Scheme, or ML.

Profile